fork download
  1. #import <objc/objc.h>
  2. #import <objc/Object.h>
  3. #import <Foundation/Foundation.h>
  4.  
  5. @interface Police : NSObject
  6. {}
  7.  
  8. - (NSInteger) minimalCost : (NSArray*)cost junctionInfo:(NSArray*)roads;
  9.  
  10. @end
  11.  
  12. @implementation Police
  13.  
  14. - (NSInteger) minimalCost : (NSArray*)cost junctionInfo:(NSArray*)roads
  15. {
  16. NSUInteger n = [cost count];
  17. id *e[][];
  18. for(int i=0; i<n; i++)
  19. for(int j=0; j<n; j++)
  20. e[i][j] = (BOOL)([roads[i] characterAtIndex:j] == 'Y');
  21. return 0;
  22. }
  23.  
  24. @end
  25.  
  26. int main()
  27. {
  28. id *costs = [NSArray arrayWithObjects:1,2,3,4,5];
  29. id *roads = [NSArray arrayWithObjects:@"NNNYY", @"YNNNN", @"NNNYN", @"NNYNN", "NYNNN"];
  30.  
  31. return 0;
  32. }
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.m: In function '-[Police minimalCost:junctionInfo:]':
prog.m:17:8: error: array type has incomplete element type
prog.m:18:4: error: 'for' loop initial declarations are only allowed in C99 mode
prog.m:18:4: note: use option -std=c99 or -std=gnu99 to compile your code
prog.m:19:2: error: 'for' loop initial declarations are only allowed in C99 mode
prog.m:20:4: warning: 'NSArray' may not respond to '-characterAtIndex:'
prog.m:20:4: warning: (Messages without a matching method signature
prog.m:20:4: warning: will be assumed to return 'id' and accept
prog.m:20:4: warning: '...' as arguments.)
prog.m:20:4: error: cannot convert to a pointer type
prog.m:20:51: warning: comparison between pointer and integer
prog.m: In function 'main':
prog.m:28:2: warning: passing argument 1 of 'arrayWithObjects:' makes pointer from integer without a cast
prog.m:28:2: note: expected 'id' but argument is of type 'int'
prog.m:28:14: warning: initialization from incompatible pointer type
prog.m:29:14: warning: initialization from incompatible pointer type
stdout
Standard output is empty