题目链接:
http://acm.hdu.edu.cn/showproblem.php?pid=5774
题目大意:
已知1946~2015每一年赢得人是谁,给n个名字,问赢了多少次。
题目思路:
【模拟】
打个表就好。
1 #include<stdio.h> 2 #include<string.h> 3 char list[100][35]= 4 {"Cleveland Cavaliers", 5 "Golden State Warriors", 6 "San Antonio Spurs", 7 "Miami Heat", 8 "Miami Heat", 9 "Dallas Mavericks", 10 "L.A. Lakers", 11 "L.A. Lakers", 12 "Boston Celtics", 13 "San Antonio Spurs", 14 "Miami Heat", 15 "San Antonio Spurs", 16 "Detroit Pistons", 17 "San Antonio Spurs", 18 "L.A. Lakers", 19 "L.A. Lakers", 20 "L.A. Lakers", 21 "San Antonio Spurs", 22 "Chicago Bulls", 23 "Chicago Bulls", 24 "Chicago Bulls", 25 "Houston Rockets", 26 "Houston Rockets", 27 "Chicago Bulls", 28 "Chicago Bulls", 29 "Chicago Bulls", 30 "Detroit Pistons", 31 "Detroit Pistons", 32 "L.A. Lakers", 33 "L.A. Lakers", 34 "Boston Celtics", 35 "L.A. Lakers", 36 "Boston Celtics", 37 "Philadelphia 76ers", 38 "L.A. Lakers", 39 "Boston Celtics", 40 "L.A. Lakers", 41 "Seattle Sonics", 42 "Washington Bullets", 43 "Portland Trail Blazers", 44 "Boston Celtics", 45 "Golden State Warriors", 46 "Boston Celtics", 47 "New York Knicks", 48 "L.A. Lakers", 49 "Milwaukee Bucks", 50 "New York Knicks", 51 "Boston Celtics", 52 "Boston Celtics", 53 "Philadelphia 76ers", 54 "Boston Celtics", 55 "Boston Celtics", 56 "Boston Celtics", 57 "Boston Celtics", 58 "Boston Celtics", 59 "Boston Celtics", 60 "Boston Celtics", 61 "Boston Celtics", 62 "St. Louis Hawks", 63 "Boston Celtics", 64 "Philadelphia Warriors", 65 "Syracuse Nats", 66 "Minneapolis Lakers", 67 "Minneapolis Lakers", 68 "Minneapolis Lakers", 69 "Rochester Royals", 70 "Minneapolis Lakers", 71 "Minneapolis Lakers", 72 "Baltimore Bullets", 73 "Philadelphia Warriors"}; 74 int main() 75 { 76 int cas,i,j,ans; 77 char temp[35]; 78 scanf("%d\n",&cas); 79 for(i=1;i<=cas;i++) 80 { 81 gets(temp); 82 printf("Case #%d: ",i); 83 ans=0; 84 for(j=0;j<115-46+1;j++) 85 if (strcmp(temp,list[j])==0) ans++; 86 printf("%d\n",ans); 87 } 88 return 0; 89 }
本文介绍了一种通过算法统计1946年至2015年NBA冠军队伍获胜次数的方法。使用C语言实现,通过创建一个包含历年冠军队伍名称的数组,然后遍历数组来计数每个队伍的胜利次数。
1076

被折叠的 条评论
为什么被折叠?



