zoukankan      html  css  js  c++  java
  • 选择排序

        //选择排序  思想: 每次选择当前序列中的最大值
        NSMutableArray *sortSelect = [NSMutableArray arrayWithObjects:@12, @25, @0, @31, @20, nil];
        
        int m,n;
        NSNumber *temp;
        for (m = 0; m < sortSelect.count - 1; m++) {
            for (n = m + 1; n < sortSelect.count; n++) {
                if (sortSelect[n] < sortSelect[m]) {
                    temp = sortSelect[n];
                    sortSelect[n] = sortSelect[m];
                    sortSelect[m] = temp;
                }
            }
        }
        
        for (NSNumber *num in sortSelect) {
            NSLog(@"%@", num);
        }

     
  • 相关阅读:
    电话续
    邀请
    Detecting versions of IE
    Android命令行
    电话
    性格形容词
    .NET 异常处理
    uva 10161 Ant on a Chessboard
    转载 ACM训练计划
    uva 253 Cube painting
  • 原文地址:https://www.cnblogs.com/tian-sun/p/4271003.html
Copyright © 2011-2022 走看看