zoukankan      html  css  js  c++  java
  • 排序 从小到大。

    #include "Head.c"
    void main()             /*排序*/
    {
            int num[10];
            int i,j;
            int temp;       /*中间存取变量*/

            printf("请输入十个数字。/n");

            for( i = 0 ; i < 10 ; i++)
            {
                    printf("请输入第%d个数:", i + 1);
                    scanf("%d",&num[i]);
            }//End for;记录刚才输入的十个数。

            for(i = 0 ; i < 9 ; i++)                /*开始进行排序操作*/
            {
                    for( j = i + 1 ; j < 10 ; j++)
                    {
                            if( num[i] > num[j] )
                            {
                                    temp = num[i] ;
                                    num[i] = num[j] ;
                                    num[j] = temp ;
                            }//End if;
                    }//End for;
            }//End for;

            for(i = 0 ; i < 10 ; i++)
            {
                    printf("%d/n",num[i]);
            }//End for;从小到大打印出来。
    }//End main(); 

    Head.c
    #include<string.h>
    #include<stdio.h>
    #include<math.h>
    #include<ctype.h>       //函数库 toupper;
    #include<stdlib.h>      //Exit(0) 函数库;

  • 相关阅读:
    Linux删除文件相关命令
    Bing语句
    VS2013配置Winpcap
    node10-mongoose
    node09-cookie
    node08-express
    node07-http
    node06-path
    node05-fs
    node04-buffer
  • 原文地址:https://www.cnblogs.com/xiaotuni/p/2365720.html
Copyright © 2011-2022 走看看