Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
Objective C- Hacker Earth
#import <Foundation/Foundation.h>
@interface FindVowels
{
}
-(int) findVowel:(int)x;
@end
@implementation FindVowels
-(int) findVowel:(char)x {
if(x >= 97)
{
x -= 32;
}
if(x == 'A' || x == 'E' || x == 'I' || x == 'O' || x == 'U')
{
return 1;
}
return 0;
}
@end
int main(int argc, const char* argv[]){
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
int kases;
scanf("%d",&kases);
int count = 0;
while(kases--)
{
char str[999999];
scanf("%s",str);
count = 0 ;
for(int i = 0; i<strlen(str); i++) {
if([FindVowels findVowel:str[i]] == 1)
{
count++;
}
//if (strchr(foo, 'a') != NULL)
}
printf("%d \n",count);
}
[pool drain];
return 0;
}
#import <Foundation/Foundation.h>
int main(int argc, const char* argv[]){
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
int noInputs;
scanf("%d", &noInputs);
int findNo;
scanf("%d", &findNo);
int index = -1;
if(noInputs>0)
{
for(int kase = 1; kase <= noInputs; kase++) {
int N;
scanf("%d", &N);
if(N == findNo)
{
index = kase;
}
}
}
printf("%d",index);
[pool drain];
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment