-
Notifications
You must be signed in to change notification settings - Fork 0
/
5-b5.cpp
50 lines (50 loc) · 998 Bytes
/
5-b5.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
//2151753 彭坤宇 计科
#include<iostream>
using namespace std;
int main()
{
int i, k = 1000, result[1001];
int chengji;
int number = 0;
int sum = 0, x;
cout << "请输入成绩(最多1000个),以-1结束" << endl;
for (i = 0; i < 1001; i += 1) {
cin >> result[i];
if (result[i] < 0) {
k = i;
break;
}
}
if (k == 0) {
cout << "无有效输入" << endl;
return 0;
}
else {
int flag = 1;
cout << "输入的数组为:" << endl;
for (i = 0; i < k; i += 1) {
cout << result[i] << " ";
if ((i + 1) % 10 == 0) {
if (i + 1 == k)
flag = 0;
cout << endl;
}
}
if(flag)
cout << endl;
cout << "分数与名次的对应关系为:" << endl;
for (chengji = 100; chengji > -1; chengji--) {
for (i = 0; i < k; i += 1) {
if (result[i] == chengji) {
number++;
}
}
sum = sum + number;
for (x = number; x > 0; x--) {
cout << chengji << " " << sum - number + 1 << endl;
}
number = 0;
}
return 0;
}
}