16.次数差

16.次数差_第1张图片

思路:本题思路只是不用看题可以直接看输出描述,就是用map或者数组去储存每个字母出现的次数

#include 
#include
#include
using namespace std;
int main()
{
   string str;
   cin>>str;
   int i,j;
   maph;
   for(auto s:str){
     h[s]++;
   }
   int minop=h[str[0]];
   int maxop=h[str[0]];
   for(auto s:str){
      maxop=max(maxop,h[s]);
      minop=min(minop,h[s]);
   }
   cout<

 

你可能感兴趣的:(蓝桥杯每年真题,c++,算法,数据结构)