您的位置:首页 > 其它

阿里笔试:去重和排序,重新输出Markdown格式

2017-03-09 11:10 288 查看


#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <map>

using namespace std;

int main()
{
string str;
map<int, int> j_1_mp, j_2_mp, content;
while (cin >> str)
{

if (str[0] == '#'&&str[1] != '#')
{
string numstr;
for (int i = 1; i < str.length(); ++i) numstr[i - 1] = str[i];
if (j_1_mp.find(atoi(numstr.c_str())) == j_1_mp.end())
{
j_1_mp[atoi(numstr.c_str())]++;
cout << str << endl;
}
else
continue;

}
else if (str[0] == '#'&&str[1] == '#'){
string numstr;
for (int i = 2; i < str.length(); ++i) numstr[i - 2] = str[i];
if (j_2_mp.find(atoi(numstr.c_str())) == j_2_mp.end()){
j_2_mp[atoi(numstr.c_str())]++;
cout << str << endl;
}
else
continue;
}
else{
string numstr;
for (int i = 1; i < str.length(); ++i) numstr[i - 1] = str[i];
if (content.find(atoi(numstr.c_str())) == content.end())
{
content[atoi(numstr.c_str())]++;
cout << str << endl;
}
else
continue;
}

}

return 0;
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐