本来是想用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. BZOJ 3270: 博物馆

    Sol 期望DP+高斯消元. 根据本题题意列出期望方程\[E(i,j)=(1-p_i)(1-p_j)E(u,v)+(1-p_i)p_jE(u,j)+p_i(1-p_j)E(i,v)+p_ip_jE(i ...

  2. 开始做POI啦...

    库 为了效率搞了这么一个库: 现在版本号1.14(一月十四日更新版本囧..) http://pan.baidu.com/s/1c0SoGfu [source] http://pan.baidu.com ...

  3. JS 对象遍历

    var orgRoot = { 271: {backgroundColor: '#f68f2b', textColor: '#FFFFFF'}, 272: {backgroundColor: '#49 ...

  4. neutron 同一虚拟网卡的多个IP设置

    neutron port-update <端口ID> --fixed-ip subnet_id=<子网ID/子网名>,ip_address=<IP地址> --fix ...

  5. 如何查看Git对象

    原文:http://gitbook.liuhui998.com/7_2.html 如果在阅读本文之前,你还不知道git是如何进行存储的,请先阅读<Git是如何存储对象的>. 我们可以使用c ...

  6. C# 毕业证书打印《五》

    对鼠标操作Label的方法 #region //定义一个枚举类型,描述光标状态 private enum EnumMousePointPosition { #region MouseSizeNone ...

  7. Closest Binary Search Tree Value I & II

    Closest Binary Search Tree Value Given a non-empty binary search tree and a target value, find the v ...

  8. C++中的结构体

    http://zhidao.baidu.com/link?url=8OYQSKV9mvSBc6Hkf9NsLQmipSge9VCZDJQGAZZs5PCBQ54UTmK98VRmAklEEAFYu7d ...

  9. 【leetcode】Reverse Nodes in k-Group

    Reverse Nodes in k-Group Given a linked list, reverse the nodes of a linked list k at a time and ret ...

  10. PyCharm 4.0.6 注册码

    Professional Edition版本比Free版本多了很多东西,比如 Web development,Django等等,重新下了Professional版本,虽然是只30天免费,但是到时候重装 ...