1.链接地址
https://vjudge.net/problem/POJ-3224
2.问题描述
The Lab Cup Table Tennis Competition is going to take place soon among laboratories in PKU. Students from the AI Lab are all extreme enthusiasts in table tennis and hold strong will to represent the lab in the competition. Limited by the quota, however, only one of them can be selected to play in the competition.
To make the selection fair, they agreed on a single round robin tournament, in which every pair of students played a match decided by best of 5 games. The one winning the most matches would become representative of the lab. Now Ava, head of the lab, has in hand a form containing the scores of all matches. Who should she decide on for the competition?
输入样例
4 0 0 3 2 3 0 3 1 2 2 0 2 3 3 3 0
输出样例
4
3.解题思路
就是找出每一行3最多的那个人,一样多则取在前的那一位
4.算法实现源代码
#include <iostream> using namespace std; int main() { int n; int a[105][105]; cin>>n; for(int i = 0; i < n; i++) for(int j = 0; j < n; j++) cin>>a[i][j]; int maxIndex = 0; int max = 0; for(int i = 0; i < n; i++) { int sum = 0; for(int j = 0; j < n; j++) { if(a[i][j] == 3) sum++; } if(sum > max) { max = sum; maxIndex = i; } } cout<<maxIndex+1<<endl; return 0; }