问题: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的和问题的更多相关文章

  1. SQL Server 中怎么查看一个字母的ascii编码或者Unicode编码

    参考文章:微信公众号文章 在sql中怎么查看一个字符的ascii编码,so easy !! select ASCII('a') SELECT CHAR(97) charNum SELECT UNICO ...

  2. perl 如何匹配ASCII码以及ASCII码转换

    匹配ASCII码:   /[:ascii:]/ ASCII码转换为数字: ord() 数字转换为ASCII码: chr()

  3. 常用ASCII CHR碼對照

    因為開發需求,把對照表留下來一下. Chr(0) Null Chr(29) 分组符 Chr(38) & Chr(48) 0 Chr(8) 退格 Chr(30) 記錄分離符號 Chr(39) ‘ ...

  4. ascii、unicode、utf、gb等编码详解

    很久很久以前,有一群人,他们决定用8个可以开合的晶体管来组合成不同的状态,以表示世界上的万物.他们看到8个开关状态是好的,于是他们把这称为"字节".再后来,他们又做了一些可以处理这 ...

  5. ASCII码而已

    题目: \u5927\u5bb6\u597d\uff0c\u6211\u662f\u0040\u65e0\u6240\u4e0d\u80fd\u7684\u9b42\u5927\u4eba\uff01 ...

  6. 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 ...

  7. ASCII码、Unicode码 转中文

    ASCII码.Unicode码 转中文 在最近工作中遇到了一些汉字编码转换的处理,可以通过正则表达式及转换字符来实现转成中文 Unicode转换示例 通常为10位编码, 通过digit参数传入 pri ...

  8. ASCII字符集中的功能/控制字符

       ASCII字符集中的功能/控制字符     Function/Control Code/Character in ASCII Version: 2011-02-15 Author: gree ...

  9. ASCII和16进制对照表

    十六进制代码 MCS 字符或缩写 DEC 多国字符名 ASCII 控制字符 1 00 NUL 空字符 01 SOH 标题起始 (Ctrl/A) 02 STX 文本起始 (Ctrl/B) 03 ETX ...

  10. Oracle中的CHR()函数与ASCII()函数

    工作中经常会处理一些因特殊字符而导致的错误,如上周我就遇到了因为换行符和回车符导致的数据上报的错误,这种错误比较难以发现,通常是由于用户的输入习惯导致的,有可能数据极少,就那么几行错误从而导致整个数据 ...

随机推荐

  1. UVALive 6663 Count the Regions --离散化+DFS染色

    题意:给你n(n<=50)个矩形(左上角坐标和右下角坐标),问这些矩形总共将平面分成多少个部分.坐标值可能有1e9. 分析:看到n和坐标的范围,容易想到离散化,当时就没想到离散化以后怎么判断区域 ...

  2. MySQL数据库学习笔记(六)----MySQL多表查询之外键、表连接、子查询、索引

    本章主要内容: 一.外键 二.表连接 三.子查询 四.索引 一.外键: 1.什么是外键 2.外键语法 3.外键的条件 4.添加外键 5.删除外键 1.什么是外键: 主键:是唯一标识一条记录,不能有重复 ...

  3. AppScan Source V8.8 中弃用的功能

    从 AppScan Source V8.8 开始,不再支持以下操作系统: Microsoft Windows XP Microsoft Windows Server 2003,所有版本和修订版   此 ...

  4. 八、Foundation -常用结构体

    一.NSRange 在foundation/NSRange.h中对NSRange的定义 typedef struct _NSRange{ NSUInteger location; NSUInteger ...

  5. 如何获取内联样式的width值

    如图,如何获取内联样式的width值 不用attr 用css这样写

  6. 【C#】【Thread】SynchronizationContext线程间同步

    SynchronizationContext在通讯中充当传输者的角色,实现功能就是一个线程和另外一个线程的通讯. 需要注意的是,不是每个线程都附加SynchronizationContext这个对象, ...

  7. [Erlang37]error/1 exit/1 exit/2 throw/1的区别

    1. error/1 主要是系统用来定义内部错误的: Erlang内建的run time error 一共有10种: function_clause/case_clause/if_clause/bad ...

  8. Elasticsearch集群中处理大型日志流的几个常用概念

    之前对于CDN的日志处理模型是从logstash agent==>>redis==>>logstash index==>>elasticsearch==>&g ...

  9. C# lambda表达式及初始化器

    using System;using System.Collections.Generic; using System.Linq; namespace ConsoleApplication1d { c ...

  10. 做leetcode的几点体会分享(转)

    1 大部分题目你都是可以自己做出来的.所以,第一遍尽量不要网上找答案: 2 写了的不管通过的,不通过的答案要保存下来.不通过的,也要记录下来哪儿没有通过.很有可能你这次错了,不知道怎么搞过了,下次还是 ...