最大ASCII的和问题
问题:One day when you are going to clear all your browsing history, you come up with an idea: You want to figure out what your most valued site is. Every site is given a value which equals to the sum of ASCII values of all characters in the URL. For example aa.cc has value of 438 because 438 = 97 + 97 + 46 + 99 + 99. You just need to print the largest value amongst all values of sites.
Things are simplified because you found that all entries in your browsing history are of the following format: [domain], where [domain] consists of lower-case Latin letters and “.” only. See the sample input for more details.
Input
There are several test cases.
For each test case, the first line contains an integer n (1 ≤ n ≤ 100), the number of entries in your browsing history.
Then follows n lines, each consisting of one URL whose length will not exceed 100.
Input is terminated by EOF.
Output
For each test case, output one line “Case X: Y” where X is the test case number (starting from 1) and Y is a number indicating the desired answer.
Sample Input
1
aa.cc
2
www.google.com
www.wikipedia.org
Sample Output
Case 1: 438
Case 2: 1728
回答:题意就是给n个字符串,求最大ASCII码和。
#include <stdio.h>
#include <string.h>
int main() {
int n, t = 0;
while(scanf("%d", &n)!=EOF) {
int maxx = 0;
while(n--) {
int i, tmp = 0;
char s[105];
scanf("%s", s);
for(i = 0; s[i]; i++)
tmp += s[i];
if(tmp > maxx)
maxx = tmp;
}
printf("Case %d: %d\n", ++t, maxx);
}
return 0;
}
最大ASCII的和问题的更多相关文章
- SQL Server 中怎么查看一个字母的ascii编码或者Unicode编码
参考文章:微信公众号文章 在sql中怎么查看一个字符的ascii编码,so easy !! select ASCII('a') SELECT CHAR(97) charNum SELECT UNICO ...
- perl 如何匹配ASCII码以及ASCII码转换
匹配ASCII码: /[:ascii:]/ ASCII码转换为数字: ord() 数字转换为ASCII码: chr()
- 常用ASCII CHR碼對照
因為開發需求,把對照表留下來一下. Chr(0) Null Chr(29) 分组符 Chr(38) & Chr(48) 0 Chr(8) 退格 Chr(30) 記錄分離符號 Chr(39) ‘ ...
- ascii、unicode、utf、gb等编码详解
很久很久以前,有一群人,他们决定用8个可以开合的晶体管来组合成不同的状态,以表示世界上的万物.他们看到8个开关状态是好的,于是他们把这称为"字节".再后来,他们又做了一些可以处理这 ...
- ASCII码而已
题目: \u5927\u5bb6\u597d\uff0c\u6211\u662f\u0040\u65e0\u6240\u4e0d\u80fd\u7684\u9b42\u5927\u4eba\uff01 ...
- python2.7 报错(UnicodeDecodeError: 'ascii' codec can't decode byte 0xe6 in position 0: ordinal not in range(128))
报错: 原来用的python3.5版本后来改为2.7出现了这个错误里面的中文无法显示 UnicodeDecodeError: 'ascii' codec can't decode byte 0xe6 ...
- ASCII码、Unicode码 转中文
ASCII码.Unicode码 转中文 在最近工作中遇到了一些汉字编码转换的处理,可以通过正则表达式及转换字符来实现转成中文 Unicode转换示例 通常为10位编码, 通过digit参数传入 pri ...
- ASCII字符集中的功能/控制字符
ASCII字符集中的功能/控制字符 Function/Control Code/Character in ASCII Version: 2011-02-15 Author: gree ...
- ASCII和16进制对照表
十六进制代码 MCS 字符或缩写 DEC 多国字符名 ASCII 控制字符 1 00 NUL 空字符 01 SOH 标题起始 (Ctrl/A) 02 STX 文本起始 (Ctrl/B) 03 ETX ...
- Oracle中的CHR()函数与ASCII()函数
工作中经常会处理一些因特殊字符而导致的错误,如上周我就遇到了因为换行符和回车符导致的数据上报的错误,这种错误比较难以发现,通常是由于用户的输入习惯导致的,有可能数据极少,就那么几行错误从而导致整个数据 ...
随机推荐
- 程序4-5 打开一个文件,然后unlink
//http://blog.chinaunix.net/uid-24549279-id-71355.html /* ========================================== ...
- RDLC直接打印帮助类
代码 /// <summary> /// 打印帮助类 /// </summary> public class PrintHelper { private int m_curre ...
- android实现点击背景图片不同区域实现不同事件
有时候我们拿到一张背景图片,客户要求点击图片的不同区域去跳转或者实现不同的操作事件.我们首先要确认图片的点击区域,往往我们会在布局文件那里下手,但是这样不好做适配,所以我实现了以下方法,基本功能可以实 ...
- linux添加时间提示符
给PS1添加\t [root@lanny ~]# echo $PS1 [\u@\h \W]\$ [root@lanny ~]# export PS1="[\u@\h \W\t]\$" ...
- 小程序基础02:全局配置app.json
1.配置 我们使用app.json文件来对来微信小程序进行全局配置. 作用:他决定了页面文件的路径,窗口表现,设置网络超时时间,设置多tab等 每一个小程序页面也可以使用 .json 文件来对本页面的 ...
- Python快速教程 尾声(转)
原文地址: http://www.cnblogs.com/vamei/p/3603046.html 作者:Vamei 出处:http://www.cnblogs.com/vamei 欢迎转载,也请保留 ...
- [CareerCup] 2.1 Remove Duplicates from Unsorted List 移除无序链表中的重复项
2.1 Write code to remove duplicates from an unsorted linked list.FOLLOW UPHow would you solve this p ...
- LeetCode:Remove Duplicates from Sorted List I II
LeetCode:Remove Duplicates from Sorted List Given a sorted linked list, delete all duplicates such t ...
- 在coding上添加ssh-key
第一步:检查有没有ssh-key 第二步:生成ssh-key 第三步:添加到coding上或者Github上. ls -al ~/.ssh ssh-keygen -t rsa -C "you ...
- 学习笔记——Maven实战(五)自动化Web应用集成测试
自动化集成测试的角色 本专栏的上一篇文章讲述了Maven与持续集成的一些关系及具体实践,我们都知道,自动化测试是持续集成必不可少的一部分,基本上,没有自动化测试的持续集成,都很难称之为真正的持续集成. ...