Advertisement
Guest User

teshka zadaca

a guest
Jan 16th, 2017
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.61 KB | None | 0 0
  1. #include <iostream>
  2. #include <iomanip>
  3. using namespace std;
  4.  
  5. int main()
  6. {
  7. string s;
  8. int n[200];
  9. int positions[200][100];
  10.  
  11. for(int i=0;i<200;i++)
  12. {
  13. n[i] = 0;
  14. }
  15. cin >> s;
  16. for(int i=0;i<s.size();i++)
  17. {
  18. positions[(int)s[i]][n[(int)s[i]]] = i;
  19. n[s[i]]++;
  20. }
  21. for(int i=0;i<200;i++)
  22. {
  23. if(n[i]>0)
  24. {
  25. cout << char(i) <<": ";
  26. for(int j=0;j<n[i];j++)
  27. {
  28. cout << positions[i][j] <<" ";
  29. }
  30. cout << endl;
  31. }
  32. }
  33. return 0;
  34. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement