hdu1860 统计字符(水题)
2015-07-23 19:37
162 查看
统计字符
Time Limit: 1000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 8570 Accepted Submission(s): 5424
Problem Description
统计一个给定字符串中指定的字符出现的次数
Input
测试输入包含若干测试用例,每个测试用例包含2行,第1行为一个长度不超过5的字符串,第2行为一个长度不超过80的字符串。注意这里的字符串包含空格,即空格也可能是要求被统计的字符之一。当读到'#'时输入结束,相应的结果不要输出。
Output
对每个测试用例,统计第1行中字符串的每个字符在第2行字符串中出现的次数,按如下格式输出:
c0 n0
c1 n1
c2 n2
...
其中ci是第1行中第i个字符,ni是ci出现的次数。
Sample Input
I THIS IS A TEST i ng this is a long test string #
Sample Output
I 2 i 3 5 n 2 g 2 注:第2个测试用例中,空格也是被统计的字符之一。
Source
浙大计算机研究生复试上机考试-2007年
Recommend
lcy | We have carefully selected several similar problems for you: 1859 1862 1861 1864 1235
Statistic | Submit | Discuss | Note
#include <stdio.h> #include <string.h> int main() { char str1[8],str2[85]; while(gets(str1)!=NULL) { if(str1[0]=='#') break; gets(str2); int len1=strlen(str1); int len2=strlen(str2); for(int i=0;i<len1;i++) { int sum=0; for(int j=0;j<len2;j++) if(str1[i]==str2[j]) sum++; printf("%c %d\n",str1[i],sum); } } return 0; }
相关文章推荐
- Oracle SQL 总结
- mySql常用SQL
- 黑马程序员——第五篇_异常
- 前端新手——stopPropagation(),preventDefault(),return false的区别
- (八十二)利用苹果服务器获取导航信息和绘制路径
- Num 9 : HDOJ: 题目1862 : 结构体排序
- 二分 poj2002 Squares
- (八十二)利用苹果服务器获取导航信息和绘制路径
- leetcode 054 —— Spiral Matrix
- PHP的MySQLi函数库的使用 以及 表单的字符编码配置
- OC基本数据类型-NSString
- python cookielib 登录人人网
- HDU 1860 统计字符
- 文件与流
- longlong 及long double类型及输出
- POJ 4020 NEERC John's inversion 贪心+归并求逆序对
- APP请求定位服务
- 关于opencv 无法成功读视频的问题
- html跳转,获取get提交参数
- C#设置默认打印机