选择排序法

来源:互联网 发布:在线画板软件 编辑:程序博客网 时间:2024/06/15 20:33
#include <stdio.h>
int main()
{
        int a[10], i, j, t;
        for (i=0; i<10; i++)
        {
                scanf("%d", &a[i]);
        }


        for (i=0; i<10; i++)
        {
                for (j=0; j<(9-i); j++)
                {
                        if (a[j]>a[9-i])
                                {
                                        t = a[j];
                                        a[j] = a[9-i];
                                        a[9-i] = t;
                                }
                }
        }
    for (i=0; i<10; i++)
        {
                printf ("%d  ", a[i]);
        }
        return 0;

}

编译单个文件...
--------
- 文件名: D:\c\suanfa\xuanzhefa.cpp
- 编译器名: TDM-GCC 4.8.1 64-bit Release


处理 C++ 源文件...
--------
- C++ 编译器: D:\soft\dev-cpp_gr\Dev-Cpp\MinGW64\bin\g++.exe
- 命令: g++.exe "D:\c\suanfa\xuanzhefa.cpp" -o "D:\c\suanfa\xuanzhefa.exe"  -I"D:\soft\dev-cpp_gr\Dev-Cpp\MinGW64\include" -I"D:\soft\dev-cpp_gr\Dev-Cpp\MinGW64\x86_64-w64-mingw32\include" -I"D:\soft\dev-cpp_gr\Dev-Cpp\MinGW64\lib\gcc\x86_64-w64-mingw32\4.8.1\include" -I"D:\soft\dev-cpp_gr\Dev-Cpp\MinGW64\lib\gcc\x86_64-w64-mingw32\4.8.1\include\c++" -L"D:\soft\dev-cpp_gr\Dev-Cpp\MinGW64\lib" -L"D:\soft\dev-cpp_gr\Dev-Cpp\MinGW64\x86_64-w64-mingw32\lib" -static-libgcc


编译结果...
--------
- 错误: 0
- 警告: 0
- 输出文件名: D:\c\suanfa\xuanzhefa.exe
- 输出大小: 361.8271484375 KiB
- 编译时间: 0.20s

0 0