Advertisement
Guest User

Untitled

a guest
Dec 8th, 2016
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.81 KB | None | 0 0
  1. #include <iostream>
  2. #include <vector>
  3. #include <string>
  4. #include <algorithm>
  5. #include <map>
  6. #include <stack>
  7. #include <set>
  8. #include <queue>
  9. #include <fstream>
  10. #include <sstream>
  11. using namespace std;
  12.  
  13. int main() {
  14. ifstream in ("input.txt");
  15. ofstream out ("output.txt");
  16. vector <pair<string, int> > a;
  17. vector <string> aa;
  18. while(in.peek() != EOF)
  19. {
  20. string str;
  21. in >> str;
  22. a.push_back(make_pair(str, 0));
  23. aa.push_back(str);
  24. }
  25. for (int j = 0; j < a.size(); j++)
  26. {
  27. a[j].second = j + 1;
  28. for (int i = j + 1; i < a.size(); i++)
  29. if (a[i].first == a[j].first)
  30.  
  31. a.erase(a.begin() + i);
  32. }
  33. for (int k = 0; k < aa.size(); k++)
  34. for (int j = 0; j < a.size(); j++)
  35. {
  36. if (aa[k] == a[j].first)
  37. out << a[j].second << " ";
  38. }
  39. in.close();
  40. out.close();
  41. return 0;
  42. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement