博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
poj2643
阅读量:7260 次
发布时间:2019-06-29

本文共 1169 字,大约阅读时间需要 3 分钟。

简单题

ContractedBlock.gif
ExpandedBlockStart.gif
View Code
#include 
#include
#include
#include
#include
using namespace std; #define maxn 25 #define maxl 100 struct Candidate {
int num; int id; } can[maxn]; int n, m; char name[maxn][maxl]; char party[maxn][maxl]; bool operator <(const Candidate &a, const Candidate &b) {
return a.num > b.num; } int getid(char *st) {
for (int i = 0; i < n; i++) if (strcmp(st, name[i]) == 0) return i; return -1; } void input() {
char st[maxl]; scanf("%d", &n); getchar(); for (int i = 0; i < n; i++) {
gets(name[i]); gets(party[i]); can[i].id = i; can[i].num = 0; } scanf("%d", &m); getchar(); for (int i = 0; i < m; i++) {
gets(st); can[getid(st)].num++; } } int main() {
//freopen("t.txt", "r", stdin); input(); sort(can, can + n); if (n > 1 && can[0].num == can[1].num) printf("tie\n"); else printf("%s\n", party[can[0].id]); return 0; }

转载于:https://www.cnblogs.com/rainydays/archive/2011/09/08/2171774.html

你可能感兴趣的文章
C++中的异常安全性【转】
查看>>
[LeetCode] Flatten Binary Tree to Linked List
查看>>
HDU 5311 Sequence
查看>>
计算日期到天数转换
查看>>
Halcon学习(八)文本操作
查看>>
ECharts(中国地图)的使用 及 非空 tooltip formatter 验证
查看>>
HDU 3579 Hello Kiki 中国剩余定理(合并方程
查看>>
(转)基于Metronic的Bootstrap开发框架经验总结(5)--Bootstrap文件上传插件File Input的使用...
查看>>
专注与极简主义
查看>>
[Node] Run Any Version of a Node Tool with npx
查看>>
Python 算法(1) 快速排序
查看>>
Redis学习第五课:Redis Set类型及操作
查看>>
Spring-更多DI的知识
查看>>
Ubuntu 16.04安装WebStorm
查看>>
DICOM:docker实现DICOM服务虚拟化
查看>>
印刷喷码字符识别,数段字符识别:易拉罐底字符识别开发说明书
查看>>
MongoDB Shell 经常使用操作
查看>>
阅读《Android 从入门到精通》(17)——进度条
查看>>
我们年轻,阳光免费
查看>>
Ruby创建命令
查看>>