poj 3224 Go for Lab Cup!
来源:互联网 发布:免费数据api 编辑:程序博客网 时间:2024/05/17 05:58
Description
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?
Input
The input contains exactly one test case. The test case starts with a line containing n (2 ≤ n ≤ 100), the number of students in the lab. Then follows an n × n matrix A. Each element in the matrix will be one of 0, 1, 2 and 3. The element at row i and column j, aij, is the number of games won by the ith student in his/her match with the jth student. Exactly one of aij and aji (i ≠ j) is 3 and the other one will be less than 3. All diagonal elements of the matrix are 0’s.
Output
Output the number of the student who won the most matches. In the case of a tie, choose the one numbered the smallest.
Sample Input
40 0 3 23 0 3 12 2 0 23 3 3 0
Sample Output
4
这是一道较为简单的水题~大致的思想就是算出哪行三的个数最多~
开一个二维数组就行了~
由于要输出序号~我用了个结构体~
输出最大值的时候我用了qsort函数~只是相练习一下这个函数的用法~其实没这个必要~
下面是代码~
#include"stdio.h"#include"stdlib.h"typedef struct in { int num; int count; };struct in a[102];int comp(const void *p1, const void *p2) //qsort使用的指针{ struct in *px, *py; px=(struct in *)p1; py=(struct in *)p2; return px->count > py->count ? 1 : 0;}int main(){ int match[102][102]; //二维数组存成绩 int n; int i,j; freopen("01in.txt","r",stdin); freopen("01out.txt","w",stdout); scanf("%d",&n); for(i=0;i<n;i++) { for(j=0;j<n;j++) scanf("%d",&match[i][j]); a[i].num=i+1; } for(i=0;i<n;i++) { a[i].count=0; for(j=0;j<n;j++) { if(match[i][j]>2) a[i].count++; } } qsort(a,n,sizeof(struct in),comp); //排序 printf("%d",a[n-1].num);}
- POJ 3224 Go for Lab Cup!
- poj 3224 Go for Lab Cup!
- poj 3224 Go for Lab Cup!
- POJ 3224 Go for Lab Cup! G++
- POJ 3224 Go for Lab Cup!(水题)
- POJ 3224 Go for Lab Cup!(水~)
- poj3224 Go for Lab Cup!
- POJ 3224 Go for Lab Cup!(我的水题之路——赢的场数最多)
- POJ 3224 Lab杯 中文
- StringProblem(for lab)
- SimpleCalculator(for lab)
- Complex number(for lab)
- POJ 3117 World Cup
- poj 3117 World Cup
- poj 3117 World Cup
- Poj 3117 World Cup
- poj-2403-cup
- POJ 3117 World Cup
- FreeMarker template error!stack.findValue(parameters.listKey) is undefined.
- 工作了之后才感觉到软件工程的重要性!
- 卸载Oracle
- 数组与指针的艺术--深入探索c/c++数组与指针的奥秘
- 菜鸟之路——第一章
- poj 3224 Go for Lab Cup!
- pb删除非空文件夹的方法
- java中关于大数据类型的处理
- 查找死锁的iis进程
- PLSQL使用oracle精简客户端连接Oracle数据库服务器
- asp.net导出excel时出错
- 关于小说《菜鸟之路》
- 怎样使用Eclipse来开发Android源码
- getchar 与 putchar