阿里笔试:去重和排序,重新输出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;
}
相关文章推荐
- [阿里一道笔试题]排序的交换次数
- 转: 冒泡排序 从键盘上接收些数(整型),存入一个线性表中,然后用冒泡排序法重新排序并输出。
- 将数组元素换成字符后重新排序输出
- 黑马程序员之c#学习笔记:按照“2012年12月21日”的格式重新输出
- 阿里校招笔试——给定一个字符串S和有效单词的字典D,请确定可以插入到S中的最小空格数,使得最终的字符串完全由D中的有效单词组成,并输出解。
- 阿里笔试:输出字符串中的出现最多的数字的和
- 让DataGrid的列按指定时间日期的格式输出和排序
- 阿里笔试题,乱序序列的保序输出。
- 笔试题:输入一串数字,以逗号隔开,将数字排序后输出
- [阿里笔试]下面代码在64位Linux系统编译执行,输出结果是____。
- 在笔试过程中进行格式的输入输出问题
- 腾讯笔试题:输入16的倍数个字符串,按格式排版输出
- 冒泡排序 从键盘上接收些数(整型),存入一个线性表中,然后用冒泡排序法重新排序并输出。
- 阿里在线笔试题---乱序到来顺序输出
- hdoj 排列2 1716 (排序&输出格式)
- NCL 读取 各种格式 然后把头文件重新定向输出到txt文件中
- HDU 1040数组输出格式&简单排序
- 数字字符串排序后重新输出
- 阿里15实习生招聘笔试 字符保序输出问题
- Hadoop MapReduce编程 API入门系列之自定义多种输入格式数据类型和排序多种输出格式(十一)