一道大水题,但是怎么说,还是学会了打表。哈哈哈
打表程序
#include<cstdio>
#include<iostream>
char str[55000][100];
int main() {
freopen("heh.txt","r",stdin);
freopen("hah.txt","w",stdout);
int i = 0;
while(gets(str[i])) i++;
for(int k = 0;k < i;k++) {
printf("strcpy(str[%d],\"",k);
for(int j = 8;str[k][j] != '\0';j++) { //像"这种符号要在前面加\
printf("%c",str[k][j]);
}
printf("\");\n");
}
}
#include<cstdio>
#include<cstring>
char str[10000][100];
int main() {
strcpy(str[0],"Cleveland Cavaliers");
strcpy(str[1],"Golden State Warriors");
strcpy(str[2],"San Antonio Spurs");
strcpy(str[3],"Miami Heat");
strcpy(str[4],"Miami Heat");
strcpy(str[5],"Dallas Mavericks");
strcpy(str[6],"L.A. Lakers");
strcpy(str[7],"L.A. Lakers");
strcpy(str[8],"Boston Celtics");
strcpy(str[9],"San Antonio Spurs");
strcpy(str[10],"Miami Heat");
strcpy(str[11],"San Antonio Spurs");
strcpy(str[12],"Detroit Pistons");
strcpy(str[13],"San Antonio Spurs");
strcpy(str[14],"L.A. Lakers");
strcpy(str[15],"L.A. Lakers");
strcpy(str[16],"L.A. Lakers");
strcpy(str[17],"San Antonio Spurs");
strcpy(str[18],"Chicago Bulls");
strcpy(str[19],"Chicago Bulls");
strcpy(str[20],"Chicago Bulls");
strcpy(str[21],"Houston Rockets");
strcpy(str[22],"Houston Rockets");
strcpy(str[23],"Chicago Bulls");
strcpy(str[24],"Chicago Bulls");
strcpy(str[25],"Chicago Bulls");
strcpy(str[26],"Detroit Pistons");
strcpy(str[27],"Detroit Pistons");
strcpy(str[28],"L.A. Lakers");
strcpy(str[29],"L.A. Lakers");
strcpy(str[30],"Boston Celtics");
strcpy(str[31],"L.A. Lakers");
strcpy(str[32],"Boston Celtics");
strcpy(str[33],"Philadelphia 76ers");
strcpy(str[34],"L.A. Lakers");
strcpy(str[35],"Boston Celtics");
strcpy(str[36],"L.A. Lakers");
strcpy(str[37],"Seattle Sonics");
strcpy(str[38],"Washington Bullets");
strcpy(str[39],"Portland Trail Blazers");
strcpy(str[40],"Boston Celtics");
strcpy(str[41],"Golden State Warriors");
strcpy(str[42],"Boston Celtics");
strcpy(str[43],"New York Knicks");
strcpy(str[44],"L.A. Lakers");
strcpy(str[45],"Milwaukee Bucks");
strcpy(str[46],"New York Knicks");
strcpy(str[47],"Boston Celtics");
strcpy(str[48],"Boston Celtics");
strcpy(str[49],"Philadelphia 76ers");
strcpy(str[50],"Boston Celtics");
strcpy(str[51],"Boston Celtics");
strcpy(str[52],"Boston Celtics");
strcpy(str[53],"Boston Celtics");
strcpy(str[54],"Boston Celtics");
strcpy(str[55],"Boston Celtics");
strcpy(str[56],"Boston Celtics");
strcpy(str[57],"Boston Celtics");
strcpy(str[58],"St. Louis Hawks");
strcpy(str[59],"Boston Celtics");
strcpy(str[60],"Philadelphia Warriors");
strcpy(str[61],"Syracuse Nats");
strcpy(str[62],"Minneapolis Lakers");
strcpy(str[63],"Minneapolis Lakers");
strcpy(str[64],"Minneapolis Lakers");
strcpy(str[65],"Rochester Royals");
strcpy(str[66],"Minneapolis Lakers");
strcpy(str[67],"Minneapolis Lakers");
strcpy(str[68],"Baltimore Bullets");
strcpy(str[69],"Philadelphia Warriors");
int t;
scanf("%d",&t);
getchar();
char str1[100];
for(int k = 1;k <= t;k++) {
gets(str1);
int ans = 0;
for(int i = 0;i <= 69;i++)
if(strcmp(str1,str[i]) == 0)
ans++;
printf("Case #%d: %d\n",k,ans);
}
}