Advertisement
katethegreat_18

PE11

Sep 18th, 2020
900
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. // pls change variables
  2.  
  3. #import <Foundation/Foundation.h>
  4.  
  5. int main(int argc, const char * argv[]) {
  6.     @autoreleasepool {
  7.         NSMutableArray *studentList = [[NSMutableArray alloc]init];
  8.         NSString *student = [[NSString alloc]init];
  9.         NSArray *finalList = [[NSArray alloc]init];
  10.        
  11.         char name[50];
  12.         int i;
  13.         for (i=1; i<=10; i++) {
  14.             NSLog(@"Input name: %d", i);
  15.             gets(name);
  16.             student = [NSString stringWithFormat:@"%s", name];
  17.             [studentList addObject:student];
  18.            
  19.         }
  20.        
  21.         finalList = [studentList sortedArrayUsingSelector:@selector(localizedCaseInsensitiveCompare:)];
  22.         NSLog(@"Students that are present: ");
  23.         for (i=0; i<studentList.count; i++) {
  24.             NSLog(@"%@", [finalList objectAtIndex:i]);
  25.         }
  26.        
  27.     }
  28.     return 0;
  29. }
  30.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement