题目大意:先依次给出字符串, 如果前面这个字符串没有出现过就输出ok, 否则输出该字符串并在某位加上数字,表明是第几次重复出现。
思路:用map水果
code:
#include <iostream>
#include <algorithm>
#include <map>
using namespace std;
int main()
{
int i = 0, j = 0, k = 0, n = 0;
string s;
while(cin>>n)
{
map<string, int> mymap;
while(n--)
{
cin>>s;
if((k = mymap[s]++) == 0) cout<<"OK"<<endl;
else
cout<<s<<k<<endl;
}
}
return 0;
}