游客 Signup | Login
中文 | En

1702 - 2006年春浙江省计算机等级考试二级C 编程题(1)

编写程序,输入一批学生的成绩,遇0或负数则输入结束,要求统计并输出优秀(大于85)、通过(6084)和不及格(小于60)的学生人数。

运行示例:


Input

Output

Examples

Input

88 71 68 70 59 81 91 42 66 77 83 0

Output

>=85:2
60-84:7
<60:2

Solution C

#include<stdio.h>

 

int main()

{

   int high=0,mid=0,low=0;

   int x;

   while(scanf("%d",&x), x>0)

   {

      if(x >= 85)

         high++;

      else if(x >= 60)

         mid++;

      else

         low++;

   }

   printf(">=85:%d\n60-84:%d\n<60:%d\n",high,mid,low);

 

   return 0;

}

Solution C++

#include<iostream>
using namespace std;
int main()
{
	int x,a=0,b=0,c=0;
	while (cin>>x && x>0)
		if (x>=85) a++;
		else if(x>=60) b++;
		else c++;
	cout<<">=85:"<<a<<endl;
	cout<<"60-84:"<<b<<endl;
	cout<<"<60:"<<c<<endl;
	return 0;
}
Time Limit 1 second
Memory Limit 128 MB
Discuss Stats
上一题 下一题