解题思路:
定义数组用于接收数据,在接收的时候判断是否符合要求,符合要求则进行计数,遇到退出条件时则退出并输出最后结果
注意事项:
参考代码:
#include<iostream>
using namespace std;
int main()
{
int a[1000];
int b = 0; int c = 0; int d = 0;
for (int i = 0; i < 1000; i++)
{
cin >> a[i];
if (a[i] >= 85)
b++;
else if (a[i] >= 60 && a[i] <= 84)
c++;
else if (a[i] > 0 && a[i] < 60)
d++;
else if (a[i] <= 0)
break;
}
cout << ">=85:" << b << endl << "60-84:" << c << endl << "<60:" << d;
return 0;
}
0.0分
0 人评分