Browsing History

hdu4464:http://acm.hdu.edu.cn/showproblem.php?pid=4464

题意:就是统计n个字符串中每个字符串每个字符对印的Asci,然后输出最大的长度。

题解:水题,注意一个技巧:字符对应的asci 直接int a=(int )c(c是字符类型即可)。

 1 #include<iostream>
 2 #include<cstdio>
 3 #include<cstring>
 4 #include<algorithm>
 5 using namespace std;
 6 char  str[1000];
 7 int main(){
 8    int tt=1,n,ans=0,temp;
 9    while(~scanf("%d",&n)){
10        ans=0;
11     while(n--){
12      memset(str,0,sizeof(str));
13      scanf("%s",str);
14      int len=strlen(str);
15         temp=0;
16      for(int i=0;i<len;i++){
17         temp+=(int)str[i];
18        }
19       ans=max(ans,temp);
20     }
21      printf("Case %d: %d\n",tt++,ans);
22 
23    }
24 }
View Code

 

posted on 2014-06-18 23:54  天依蓝  阅读(149)  评论(0编辑  收藏  举报

导航