poj3224

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

 

转载于:https://www.cnblogs.com/KasenBob/p/11176996.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值