Created
October 10, 2017 16:24
-
-
Save vizllx/2902b0b313df8859c31d25e75f1c27e9 to your computer and use it in GitHub Desktop.
Objective C- Hacker Earth
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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