| Time Limit: 1000MS | Memory Limit: 65536K | |
| Total Submissions: 5445 | Accepted: 2610 |
Description
To help in the renovation, the Alumni Association of the University decided to organize a series of fund-raising dinners, for which all alumni were invited. These events proved to be a huge success and several were organized during the past year. (One of the reasons for the success of this initiative seems to be the fact that students that went through the Pascal system of education have fond memories of that time and would love to see a renovated Pascal Library.)
The organizers maintained a spreadsheet indicating which alumni participated in each dinner. Now they want your help to determine whether any alumnus or alumna took part in all of the dinners.
Input
Output
Sample Input
3 3 1 1 1 0 1 1 1 1 1 7 2 1 0 1 0 1 0 1 0 1 0 1 0 1 0 0 0
Sample Output
yes no
Hint
Alumnus: a former male student of a particular school, college or university.
Alumni: former students of either sex of a particular school, college or university.
题意:统计二维矩阵的列中出现1的个数,如果个数等于列数,就输出yes,否则输出no!
参考代码:
#include <iostream>
using namespace std;
int map[101][501];
int main(){
int m,n;
while (cin>>m>>n){
if (m==0&&n==0) continue;
int flag=0;
for (int i=0;i<m;i++){
int num=0;
for (int j=0;j<n;j++){
cin>>map[i][j];
if (map[i][j]==1)
num++;
}
if (num==n){
flag=1;
}
}
if (flag==1)
cout<<"yes"<<endl;
else
cout<<"no"<<endl;
}
return 0;
}
364



被折叠的 条评论
为什么被折叠?



