用oc编的,但是运行了部队,求改错#import <Foundation/Foundation.h>
int main(int argc, const char * argv[]) { @autoreleasepool { NSMutableArray *array=[NSMutableArray arrayWithObjects:@"2",@"3",@"1", nil]; //冒泡排序 for(int i=0;i<array.count-1;i++){ for(int j=0;j<array.count-i-1;j++){ if(array[j]>array[j+1]){ [array exchangeObjectAtIndex:j withObjectAtIndex:(j+1)]; } } } NSLog(@"%@",array); NSLog(@"最小值为%@",array[0]); } return 0; }
|