输入是个学生分数,按座位或者名字之类的随机,输出是按照输入顺序然后后面加上排名
1 // C_Study.cpp : 定义控制台应用程序的入口点。 2 // 3 4 #include "stdafx.h" 5 #include <iostream> 6 7 using namespace std; 8 9 #define MAX 100 10 #define MIN 0 11 12 13 14 int _tmain(int argc, _TCHAR* argv[]) 15 { 16 int score[MAX+1]={0}; 17 int juni[MAX+2]={0}; 18 19 int count=0,i,f=0; 20 21 do{ 22 23 printf("输入分数,-1结束:"); 24 scanf("%d",&score[count++]); 25 26 }while(score[count-1]!=-1); 27 count--; 28 29 for(i=0;i<count;i++) 30 juni[score[i]]++; 31 juni[MAX+1]=1; 32 33 for(i=MAX;i>=MIN;i--) 34 juni[i]=juni[i]+juni[i+1]; 35 36 37 printf("得分排行\n"); 38 39 for(i=0;i<count;i++) 40 printf("%d %d\n",score[i],juni[score[i]+1]); 41 42 43 while(1) 44 { 45 46 } 47 return 0; 48 }