nefu 25 计算高手
2016-12-01 19:57
176 查看
计算高手
Problem:25
Time Limit:1000ms
Memory Limit:65536K
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个测试用例中,空格也是被统计的字符之一。4000
Hint
Source
//// main.cpp// shanshansahn//// Created by liuzhe on 16/8/13.// Copyright © 2016年 my_code. All rights reserved.//#include <iostream>#include <cstdio>#include <cstring>#include <algorithm>using namespace std;int main(int argc, const char * argv[]) {// insert code here...char s[105];char a[20];while(gets(a)){if(strcmp(a,"#")==0)break;gets(s);int len1=strlen(s);int len2=strlen(a);for(int i=0;i<len2;i++){int count =0;for(int j=0;j<len1;j++)if(s[j]==a[i])count++;cout<<a[i]<<' '<<count<<endl;}}//std::cout << "Hello, World!\n";return 0;}Discuss
相关文章推荐
- NEFU OJ 25 计算高手
- 实际工作中遇到的技术难题与大家交流(工作流条件表达式计算部分),希望技术高手能给于指点
- 25.根据公式计算值
- Spark GraphX宝刀出鞘,图文并茂研习图计算秘笈与熟练的掌握Scala语言【大数据Spark实战高手之路】
- 《如何计算程序员自身的价值》(2010/02/25)
- NEFU 72 计算N!
- 这个问题要求你写一个程序来计算的确切价值Rnwhere R是一个实数(0.0 < R < 99.999)和n是一个整数,0 < n < = 25。
- vs2008计算代码度量值时发生错误 高手指教
- nefu 26 计算阶乘位数
- TS科普25 TS音视频同步及PCR相关计算
- 淘宝API签名异常,如何正确计算SIGN参数?(error code:25 Invalid Signature)
- TS科普25 TS音视频同步及PCR相关计算
- 实际工作中遇到的技术难题与大家交流(工作流条件表达式计算部分),希望技术高手能给于指点
- 25-输入数字和个数计算sn=a+aa+..
- 云计算之路-阿里云上-新车限行:新购服务器无法访问任何远程25端口
- mysql 根据生日计算年龄,并查询在18-25之间的语句
- 实际工作中遇到的技术难题与大家交流(工作流条件表达式计算部分),希望技术高手能给于指点
- 云计算之路-阿里云上-新车限行:新购服务器无法访问任何远程25端口
- NEFU 561 方块计算
- 2-08. 用扑克牌计算24点(25) (ZJU_PAT 数学 枚举)