有关于getchar和gets的耗时

P1598 垂直柱状图

~~您上下两个代码不是一样的?~~
by 0nullptr @ 2019-10-28 20:56:13


~~为什么我用cin都能A~~
by pzc2004 @ 2019-10-28 20:56:50


哦贴错了,gets的AC代码是这样的qwq:@[一个python屑](/space/show?uid=82672) ```cpp #include <cstdio> #include <algorithm> #include <map> #include <cstring> using namespace std; char c[107]; int ent, maxi, num[27]; int main() { for(int i = 1; i <= 4; ++i) { gets(c); int len = strlen(c); for(int j = 0; j < len; ++j) if(c[j] >= 'A' && c[j] <= 'Z') num[c[j] - 'A']++; } for(char ch = 'A'; ch <= 'Z'; ch++) { // printf("%c appears %d time(s).\n", ch, num[ch]); maxi = max(maxi, num[ch - 'A']); } for(int i = maxi; i >= 1; --i) { if(num[0] >= i) printf("*"); else printf(" "); for(char ch = 'B'; ch <= 'Z'; ch++) if(num[ch - 'A'] >= i) printf(" *"); else printf(" "); puts(""); } printf("A B C D E F G H I J K L M N O P Q R S T U V W X Y Z"); return 0; } ```
by Eason_AC2 @ 2019-10-28 22:18:25


@[Eason_TestforAC](/space/show?uid=183771) 刚刚测了一发,这题数据有坑。#2以外的所有评测点都是以一个多余的空格结尾而不是```'\n'```。这样你用```'\n'```的数量判断就T了
by 0nullptr @ 2019-10-29 06:51:44


|