三好学生 | ||||||
| ||||||
Description | ||||||
一个班级有N个学生,M门课,如果某学生多于3门课超过了80分,那么他将被评为三好学生。 | ||||||
Input | ||||||
第1行,整数T表示有T组测试数据。 | ||||||
Output | ||||||
对于每组测试数据输出一行: | ||||||
Sample Input | ||||||
1 | ||||||
Sample Output | ||||||
2 |
参考代码:
#include<bits/stdc++.h>
using namespace std;
int main()
{
int t,n,m;
cin>>t;
while(t--&&cin>>n>>m)
{
int k,a[m],ans=0;
for(int i=0; i<n; i++)
{
k=0;
memset(a,0,sizeof(a));
for(int j=0; j<m; j++)
{
cin>>a[j];
if(a[j]>80)
k++;
}
if(k>3)
ans++;
}
cout<<ans<<endl;
}
return 0;
}