码迷,mamicode.com
首页 > 其他好文 > 详细

poj3224

时间:2019-07-12 16:57:55      阅读:105      评论:0      收藏:0      [点我收藏+]

标签:head   算法   描述   nbsp   实现   tab   链接地址   core   ora   

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;
}

 

poj3224

标签:head   算法   描述   nbsp   实现   tab   链接地址   core   ora   

原文地址:https://www.cnblogs.com/KasenBob/p/11176996.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!