码迷,mamicode.com
首页 > 编程语言 > 详细

No.5 排序问题

时间:2016-11-23 23:09:15      阅读:208      评论:0      收藏:0      [点我收藏+]

标签:scanf   print   ++   put   input   意义   学生   成绩   main   

被排序问题困扰了很久,内循环和外循环的意义总也想不太明白。
不能停顿太久了,先跳过去。

 

问题:输入10个学生的成绩,按照从大到小排序?

答案:

 

#include "stdio.h"
#include "stdlib.h"
int main()
{int a[10];
  int i,j,temp;
  printf("input score:\n");
    for(i=0;i<10;i++)
  scanf("%d",&a[i]);
  printf("\n");
  for(i=1;i<10;i++)
    for(j=0;j<9;j++)
      if(a[j]<a[j+1])
        {temp=a[j];
        a[j]=a[j+1];
        a[j+1]=temp;
        }
for(i=0;i<10;i++)
  printf("%d,",a[i]);
system("pause");
}

No.5 排序问题

标签:scanf   print   ++   put   input   意义   学生   成绩   main   

原文地址:http://www.cnblogs.com/cxr1234/p/6095161.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!