Skip to content

Instantly share code, notes, and snippets.

@vizllx
Created October 10, 2017 16:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save vizllx/2902b0b313df8859c31d25e75f1c27e9 to your computer and use it in GitHub Desktop.
Save vizllx/2902b0b313df8859c31d25e75f1c27e9 to your computer and use it in GitHub Desktop.
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