九度OJ 1018 统计同成绩学生人数
题目分析:
依次输入成绩到数组里,注意数组大小为1000,再比对给定成绩,得出人数。
源代码:
[cpp]
#include <iostream>
using namespace std;
int main()
{
int n;
while (cin>>n)
{
if (n == 0)
{
break;
}
int a[1000] = {0};
for (int i = 0; i < n; i++)
{
cin>>a[i];
}
int grade;
cin>>grade;
int j = 0;
for (int i = 0; i < n; i++)
{
if (grade == a[i])
{
j++;
}
}
cout<<j<<endl;
}
return 0;
}
#include <iostream>
using namespace std;
int main()
{
int n;
while (cin>>n)
{
if (n == 0)
{
break;
}
int a[1000] = {0};
for (int i = 0; i < n; i++)
{
cin>>a[i];
}
int grade;
cin>>grade;
int j = 0;
for (int i = 0; i < n; i++)
{
if (grade == a[i])
{
j++;
}
}
cout<<j<<endl;
}
return 0;
}
补充:软件开发 , C++ ,