#import <Foundation/Foundation.h>
void maopao(){
int arr[5] = {4,2,54,3,1};
int length = 5;
for(int i=0;i<length;i++){
for(int j=0;j<length-i-1;j++){
if(arr[j]>arr[j+1]){
int temp = arr[j];
arr[j] = arr[j+1];
arr[j+1] = temp;
}
}
}
for(int i=0;i<length;i++){
NSLog(@"%d ",arr[i]);
}
}
void xuanze(){
int arr[5] = {4,2,54,3,1};
int length = 5;
for(int i=0;i<length;i++){
for(int j=i+1;j<length;j++){
if(arr[i]>arr[j]){
int temp = arr[i];
arr[i] = arr[j];
arr[j] = temp;
}
}
}
for(int i=0;i<length;i++){
NSLog(@"%d ",arr[i]);
}
}
int main(int argc, const char * argv[]) {
@autoreleasepool {
xuanze();
maopao();
NSMutableString *str = [NSMutableString new];
[str appendString:@"abcd"];
NSLog(@"%@",str);
}
return 0;
}
|
|