栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 面试经验 > 面试问答

zoj 2984 Reaux! Sham! Beaux!

面试问答 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

zoj 2984 Reaux! Sham! Beaux!

#include <cstdio>#include <cstring>const char* Roshambo[11][4] = {    {"cs", "Kamen", "Nuzky", "Papir"},    {"en", "Rock", "Scissors", "Paper"},    {"fr", "Pierre", "Ciseaux", "Feuille"},    {"de", "Stein", "Schere", "Papier"},    {"hu", "Ko", "Ollo", "Papir"},    {"hu", "Koe", "Olloo", "Papir"},    {"it", "Sasso", "Forbice", "Carta"},    {"it", "Roccia", "Forbice", "Rete"},    {"jp", "Guu", "Choki", "Paa"},    {"pl", "Kamien", "Nozyce", "Papier"},    {"es", "Piedra", "Tijera", "Papel"}};const int roshambo[4][4] = {    {0, 0, 0, 0},    {0, 0, 1, -1},    {0, -1, 0, 1},    {0, 1, -1, 0}};int trans (char const* const type, char const* const str){    for (int i = 0; i < 11; i++)        if(strcmp(Roshambo[i][0], type) == 0) for (int j = 1; j <= 3; j++)     if(strcmp(Roshambo[i][j], str) == 0)         return j;    return 0;}class Player{public:    char name[22], type[4];    int pts;    inline void cget()    {        scanf("%s%s", type, name);        pts = 0;    }    inline void cput()    {        printf("%s: %d point%sn", name, pts, (pts == 1) ? "" : "s");    }}a, b;char buf[22];int main(void){    int ri = 0;    int aa, bb;    do {        a.cget();        b.cget();        while(true) { scanf("%s", buf); if(buf[0] == '-' || buf[0] == '.')     break; aa = trans(a.type, buf); scanf("%s", buf); bb = trans(b.type, buf); if(roshambo[aa][bb] == 1)     ++a.pts; else if(roshambo[aa][bb] == -1)     ++b.pts;        }        printf("Game #%d:n", ++ri);        a.cput();        b.cput();        if(a.pts > b.pts) printf("WINNER: %sn", a.name);        else if(a.pts < b.pts) printf("WINNER: %sn", b.name);        else printf("TIED GAMEn");        printf("n");    }while(buf[0] != '.');    return 0;}
转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/368728.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号