# c oc swift的冒泡排序

关于  C 语音的冒泡排序

<span style="color:#000000;">    <span style="font-size:18px;color:#009900;"><span style="font-size:18px;color:#009900;"></span></span></span><pre name="code" class="objc">    //对一个数组排序
int array[10]={2,8,5,4,6,7,9,0,6,3}; for (int i = 0; i<10; i++) { for (int j = 0; j< 9; j++) { if (array[j]>array[j+1]) { int temp = 0; temp = array[j]; array[j] = array[j+1]; array[j+1] = temp; } } } for (int i = 0; i<10; i++) printf("%d\n",array[i]); };

关于 OC 语音的冒泡排序

    <span style="color:#000000;">//对一个数组排序
NSMutableArray *array = [[NSMutableArray alloc]init];
for (int i = 0;i<[array count]; i++) {
for (int j = 0; j< [array count] - 1; j++) {
if ([array[j] integerValue] > [array[j+1] integerValue]) {
int a = [[array objectAtIndex:i] intValue];
int b = [[array objectAtIndex:j] intValue];
if (a>b) {
[array replaceObjectAtIndex:i withObject:[NSString stringWithFormat:@"%d",b]];
[array replaceObjectAtIndex:j withObject:[NSString stringWithFormat:@"%d",a]];
}
}
}
for (int i = 0; i<[array count]; i++)
NSLog(@"%@",[array objectAtIndex:i]);
}</span>


关于  Swift  语音的冒泡排序

<span style="font-size:18px;">var array = [2,8,5,4,6,7,9,0,6,3]
for var i = 0; i < array.count - 1; ++i {
for var j = 0; j < array.count - 1 - i; ++j{
if array[j] > array[j + 1] {
let temp = array[j + 1]
array[j + 1] = array[j]
array[j] = temp
}
}
}
print("排序后的值：")
for item in array
{
let a = item
print(a)
}</span>

#### OC的冒泡排序

2015-10-13 21:04:53

#### swift oc monkey

2018年06月13日 529KB 下载

#### 详解swift和OC以及C语言的混编(不看后悔!)

2016-05-26 08:13:00

#### 用Object-C 写一个冒泡排序

2016-05-19 17:37:19

#### iOS 算法面试题(冒泡排序、选择排序、链表逆序)~demo

2017-06-15 10:47:09

#### Objective-C调用Swift

2014-08-17 17:04:59

#### swift中导入Objective-c的第三方库（swift与oc混编）

2015-08-31 16:14:14

#### swift3.0冒泡排序

2016-10-21 09:56:36

#### Objective C转Swift注意事项(一)合理使用结构体,枚举,extensions

2016-07-10 11:21:56

#### Swift学习之和Objective-C的联系与区别

2016-07-05 10:14:34