输入是个学生分数,按座位或者名字之类的随机,输出是按照输入顺序然后后面加上排名

 

 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 }
main

相关文章:

  • 2021-04-12
  • 2022-01-16
  • 2022-12-23
  • 2021-06-12
  • 2021-06-18
  • 2022-12-23
  • 2022-02-02
  • 2022-01-24
猜你喜欢
  • 2021-12-01
  • 2022-12-23
  • 2022-02-26
  • 2021-11-25
  • 2021-04-06
  • 2022-01-06
  • 2021-06-02
相关资源
相似解决方案