Created
May 19, 2015 12:41
-
-
Save MariusCiocanel/d780074ff275ff404e73 to your computer and use it in GitHub Desktop.
HackerRank Objective-C template
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
// Created by Marius Ciocanel on 19/05/2015. | |
#import <Foundation/Foundation.h> | |
@interface Solution : NSObject | |
+(int)algorithmThatReturnsOutputFrom:(id)inputData; | |
@end | |
@implementation Solution | |
+(int)algorithmThatReturnsOutputFrom:(id)inputData { | |
// Algorighm goes here | |
return 0; | |
} | |
@end | |
int main (int argc, const char * argv[]) { | |
@autoreleasepool { | |
// Reading a number from STDIN | |
int singleValueOnOneLine; | |
scanf("%d",&singleValueOnOneLine); | |
// Reading two numbers separated by a space from STDIN | |
int firstValueOnOneLine, secondValueOnOneLine; | |
scanf("%d %d",&firstValueOnOneLine, &secondValueOnOneLine); | |
NSMutableArray *arrayOfNumbers = [NSMutableArray new]; | |
// Reading an array from STDIN | |
for (int i=0; i < singleValueOnOneLine; i++) { | |
int inputElement; | |
scanf("%d", &inputElement); | |
[arrayOfNumbers addObject:[NSNumber numberWithInt:inputElement]]; | |
} | |
// Output to STDOUT | |
printf("%ld\n",(long)[Solution algorithmThatReturnsOutputFrom:arrayOfNumbers]); | |
return 0; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment