zoukankan      html  css  js  c++  java
  • hdu 1860统计字符

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

     1 #include<time.h>
     2 #include <cstdio>  
     3 #include <iostream>  
     4 #include<iterator> 
     5 #include<algorithm>
     6 #include<math.h> 
     7 #include <string.h>  
     8 #include<vector> 
     9 #include<queue>
    10 #include<map>
    11 typedef long long int ll;
    12 using namespace std;
    13 
    14 /*
    15 int gcd(int a,int b)
    16 {
    17     return b==0?a:gcd(b,a%b);
    18 }
    19 */
    20 
    21 char c[100005],d[100005];
    22 map<char,int> m_map;
    23 
    24 
    25 int main()
    26 {
    27     int len1,len2,sum;
    28     while(gets(c)) 
    29     {
    30         if(c[0]=='#')
    31             break;
    32         gets(d);
    33         len1=strlen(c);
    34         len2=strlen(d);
    35         //m_map.clear();
    36         for(int i=0;i<len1;i++)
    37         {
    38             sum=0;
    39             for(int j=0;j<len2;j++)
    40             {
    41                 if(c[i]==d[j])
    42                     sum++;
    43             }
    44             printf("%c %d
    ",c[i],sum);
    45         }
    46         /*
    47         map<char,int>::iterator it=m_map.begin();
    48         for(it;it!=m_map.end();it++)
    49             cout<<it->first<<" "<<it->second<<endl;
    50         */
    51     }
    52     return 0;
    53  } 

    参考

  • 相关阅读:
    Spark2 Dataset DataFrame空值null,NaN判断和处理
    Spark2 文件处理和jar包执行
    &与&&, |与||区别
    Scala实现乘法口诀
    Hive desc
    Hive FUNCTIONS函数
    Hive show
    MySQL行列转换拼接
    MySQL字符串连接
    SQLServer之索引简介
  • 原文地址:https://www.cnblogs.com/pter/p/5437224.html
Copyright © 2011-2022 走看看