您的答案為: Old! 944 正確答案為: New! 2
#include<iostream>
#include<vector>
#include<algorithm>
#include<sstream>
#include<cmath>
#include<iomanip>
#include<stack>
#include<cctype>
#include<map>
#define _ ios::sync_with_stdio(false);cin.tie(0);
#define endl '\n'
using namespace std;
int main()
{_
map<string , int> mymap;
int n;
while (cin >> n)
{
int count = 1;
for (int i = 0; i < n; i++)
{
map<string, int>::iterator iter;
string s;
cin >> s;
{
iter = mymap.find(s);
if (iter != mymap.end())
{
cout << "Old! " << iter->second << endl;
}
else
{
cout << "New! " << count << endl;
mymap[s] = count;
count++;
}
}
}
}
}
如上,用map刻出來但有bug,請大神指教
您的答案為: Old! 944 正確答案為: New! 2
#include
#include
#include
#include
#include
#include
#include
#include
#include
#define _ ios::sync_with_stdio(false);cin.tie(0);
#define endl '\n'
using namespace std;
int main()
{_
map mymap;
int n;
while (cin >> n)
{
int count = 1;
for (int i = 0; i < n; i++)
{
map<string, int>::iterator iter;
string s;
cin >> s;
{
iter = mymap.find(s);
if (iter != mymap.end())
{
cout << "Old! " << iter->second << endl;
}
else
{
cout << "New! " << count << endl;
mymap[s] = count;
count++;
}
}
}
}
}
如上,用map刻出來但有bug,請大神指教
你沒有清除