本来是想用map写的,但是map里面会自动按字典序升序排序导致wa了一把,供

 #include<time.h>
#include <cstdio>
#include <iostream>
#include<iterator>
#include<algorithm>
#include<math.h>
#include <string.h>
#include<vector>
#include<queue>
#include<map>
typedef long long int ll;
using namespace std; /*
int gcd(int a,int b)
{
return b==0?a:gcd(b,a%b);
}
*/ char c[],d[];
map<char,int> m_map; int main()
{
int len1,len2,sum;
while(gets(c))
{
if(c[]=='#')
break;
gets(d);
len1=strlen(c);
len2=strlen(d);
//m_map.clear();
for(int i=;i<len1;i++)
{
sum=;
for(int j=;j<len2;j++)
{
if(c[i]==d[j])
sum++;
}
printf("%c %d\n",c[i],sum);
}
/*
map<char,int>::iterator it=m_map.begin();
for(it;it!=m_map.end();it++)
cout<<it->first<<" "<<it->second<<endl;
*/
}
return ;
}

参考

hdu 1860统计字符的更多相关文章

  1. HDOJ(HDU) 1860 统计字符

    Problem Description 统计一个给定字符串中指定的字符出现的次数 Input 测试输入包含若干测试用例,每个测试用例包含2行,第1行为一个长度不超过5的字符串,第2行为一个长度不超过8 ...

  2. hdu 1860 统计字符

    Problem Description 统计一个给定字符串中指定的字符出现的次数 Input 测试输入包含若干测试用例,每个测试用例包含2行,第1行为一个长度不超过5的字符串,第2行为一个长度不超过8 ...

  3. (count 或直接枚举) 统计字符 hdu1860

    统计字符(很水) 链接:http://acm.hdu.edu.cn/showproblem.php?pid=1860 Time Limit: 1000/1000 MS (Java/Others)    ...

  4. ACM: HDU 2563 统计问题-DFS+打表

    HDU 2563 统计问题 Time Limit:1000MS     Memory Limit:32768KB     64bit IO Format:%I64d & %I64u HDU 2 ...

  5. OpenJudge就算概论-统计字符数

    /*===================================== 统计字符数 总时间限制: 1000ms 内存限制: 65536kB 描述 判断一个由a-z这26个字符组成的字符串中哪个 ...

  6. js密码的校验(判断字符类型、统计字符类型个数)

    /** *判断字符类型 */ function CharMode(iN) { if (iN >= 48 && iN <= 57) //数字 return 1; if (iN ...

  7. 给定任意一个字符串,使用 for in 语句来统计字符出现的个数

    //找出字符串中的数字 var str = 'haj123sdk54hask33dkhalsd879'; /*function findNum(str){ var arr = []; var tmp ...

  8. excel - 统计字符个数综合案例

    本文通过一个综合的案例来介绍excel统计字符数的一些方法和思路,供大家参考和学习. 下图是一个excel数据源截图,我们逐一讲解不同条件的统计字符数. 第一,统计A2所有的字符数,不论是汉字和数字. ...

  9. Python统计字符出现次数(Counter包)以及txt文件写入

    # -*- coding: utf-8 -*- #spyder (python 3.7) 1. 统计字符(可以在jieba分词之后使用) from collections import Counter ...

随机推荐

  1. Java 的printf(转)

    出处:http://blog.csdn.net/swandragon/article/details/4653600 public class TestPrintf{public static voi ...

  2. Codeforces 260 B. Fedya and Maths

    题目链接:http://codeforces.com/contest/456/problem/B 解题报告:输入一个n,让你判断(1n + 2n + 3n + 4n) mod 5的结果是多少?注意n的 ...

  3. leetcode150 Evaluate Reverse Polish Notation

    Evaluate the value of an arithmetic expression in Reverse Polish Notation. Valid operators are +, -, ...

  4. #Deep Learning回顾#之基于深度学习的目标检测(阅读小结)

    原文链接:https://www.52ml.net/20287.html 这篇博文主要讲了深度学习在目标检测中的发展. 博文首先介绍了传统的目标检测算法过程: 传统的目标检测一般使用滑动窗口的框架,主 ...

  5. caffe学习系列(2):训练和测试自己的图片

    参考:http://www.cnblogs.com/denny402/p/5083300.html 上述主要介绍的是从自己的原始图片转为lmdb数据,再到训练.测试的整个流程(另外可参考薛开宇的笔记) ...

  6. (原创)在service中定时执行网络操作的几点说明

    执行网络操作是耗时操作,即便是在service中也要放到子线程中执行 这里我用到了async-http-client框架来执行异步请求操作 计时用的java原生Timer和TimerTask类 本来这 ...

  7. Linux_VPN—pptpd构架方法

    以下是由本人测试可用的pptpd构架方法 按步骤: 运行环境Centeros 6 *首先运行如下命令: cat /dev/net/tun 返回的必须是: cat: /dev/net/tun: File ...

  8. 【GoLang】golang 如何像Java 一样通过类名反射对象?

    结论: golang不支持解析string然后执行. golang的反射机制只能存在于已经存在的对象上面. 不知道后续的版本有没有规划,现在只能先加载注册,然后实现类似Java工厂模式的反射. 代码示 ...

  9. Interleaving Positive and Negative Numbers

    Given an array with positive and negative integers. Re-range it to interleaving with positive and ne ...

  10. git日志输出格式及两个版本之间差异列表

    查看commit id git log --pretty=format:"%h" git log --pretty=format:"%H" 获取两个版本间差异的 ...