fork download
  1. #include <iostream>
  2. #include <string>
  3.  
  4. using namespace std;
  5.  
  6. class username{
  7. public:
  8. username(string a = "A");
  9. friend istream & operator >> (istream & in, username & a);
  10. friend ostream & operator << (ostream & out, username & a);
  11. friend int isThere (int n, int a, username * base);
  12. private:
  13. string nick;
  14. };
  15.  
  16. username::username(string a){
  17. nick = a;
  18. }
  19.  
  20. istream & operator>>(istream &in, username &a){
  21. string name;
  22. in >> name;
  23. a = username(name);
  24. return in;
  25. }
  26. ostream & operator<<(ostream &out, username &a){
  27. out << a.nick;
  28. return out;
  29. }
  30.  
  31. int isThere (int n, int curPos, username * base){
  32. int c = 0;
  33. for(int i = 0; i < n; i++)
  34. if(base[curPos].nick == base[i].nick)
  35. c++;
  36. return c;
  37. }
  38.  
  39. int main()
  40. {
  41. std::ios::sync_with_stdio(false);
  42. int n = 0;
  43. cin >> n;
  44. username* nBase = new username[n];
  45. for(int i = 0; i<n; i++){
  46. cin >> nBase [i];
  47. int counter = isThere(i, i, nBase);
  48. if(counter == 0)
  49. cout << "OK" << endl;
  50. else
  51. cout << nBase[i] << counter << endl;
  52. }
  53. return 0;
  54. }
Success #stdin #stdout 0s 15240KB
stdin
Standard input is empty
stdout
Standard output is empty