标签:ural
题目链接:http://acm.timus.ru/problem.aspx?space=1&num=1612
input | output |
---|---|
of course, tram is the best transport in the world! |
Tram driver |
yes, yekaterinburg trams are the best trams in the world, but i like my trolleybus too. |
Trolleybus driver |
read forum.tr.ru every day! you can learn much about tram drivers and trolleybus drivers. |
Bus driver |
代码如下:
#include <cstdio> #include <cmath> #include <cstring> #include <string> #include <cstring> #include <vector> #include <map> #include <iostream> #include <algorithm> using namespace std; char s[10047]; int judge(char c) { if(c >= 'a' && c <= 'z') { return 1; } return 0; } int main() { char s1[17]; int a = 0, b = 0; while(~scanf("%s",&s)) { memset(s1, '\0',sizeof(s1)); int len = strlen(s); for(int i = 0; i < len; i++) { if(!judge(s[i])) { continue; } int k = 0; while(judge(s[i])) { s1[k++] = s[i]; i++; } if(strcmp(s1, "tram") == 0) { a++; } if(strcmp(s1, "trolleybus") == 0) { b++; } } } //printf("a:%d b:%d\n",a,b); if(a > b) { printf("Tram driver\n"); } else if(a < b) { printf("Trolleybus driver\n"); } else { printf("Bus driver\n"); } return 0; }
标签:ural
原文地址:http://blog.csdn.net/u012860063/article/details/44498153