高手指教一下,为什么这段代码提交后老是compile error

如题所述

第1个回答  推荐于2016-09-15
#include<iostream>
#include <fstream>
#include <string>
#include <map>
using namespace std;

int main()
{
//fstream cin("e:\\1\\1.txt");
map<char,int> cimap;
int line;
cin>>line;
string str;
for(int i = 0; i!=line; ++i)
{
cin>>str;
for(string::iterator it = str.begin(); it!=str.end(); ++it)
{
++cimap[*it];
}
int len = cimap.size();
for(map<char,int>::iterator jt = cimap.begin(); jt!=cimap.end(); ++jt)
{
jt->second==1? cout<<jt->first : cout<<jt->second<<jt->first;
}
cimap.clear();
cout<<'\n';
}
return 0;
}
Input

The first line contains an integer N (1 <= N <= 100) which indicates the number of test cases. The next N lines contain N strings. Each string consists of only 'A' - 'Z' and the length is less than 100.

Output

For each test case, output the encoded string in a line.

Sample Input

2
ABC
ABBCCC

Sample Output

ABC
A2B3C本回答被提问者和网友采纳

相关了解……

你可能感兴趣的内容

本站内容来自于网友发表,不代表本站立场,仅表示其个人看法,不对其真实性、正确性、有效性作任何的担保
相关事宜请发邮件给我们
© 非常风气网