zoukankan      html  css  js  c++  java
  • poj2643

    简单题

    View Code
    #include <iostream>
    #include
    <cstdlib>
    #include
    <cstring>
    #include
    <cstdio>
    #include
    <algorithm>
    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;
    }
  • 相关阅读:
    onclick中的函数的参数this
    classList的使用
    设置点击鼠标时不跳转
    模块补充shutil,logging
    re模块拾遗和递归函数
    正则表达式-re模块
    软件开发规范
    自定义模块2
    常用模块
    初识自定义模块
  • 原文地址:https://www.cnblogs.com/rainydays/p/2171774.html
Copyright © 2011-2022 走看看