Advertisement
Guest User

teshka zadaca so funkcija

a guest
Jan 16th, 2017
65
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.67 KB | None | 0 0
  1. #include <iostream>
  2. #include <iomanip>
  3. using namespace std;
  4.  
  5. void findChars(string s)
  6. {
  7.  
  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. for(int i=0;i<s.size();i++)
  16. {
  17. positions[(int)s[i]][n[(int)s[i]]] = i;
  18. n[s[i]]++;
  19. }
  20. for(int i=0;i<200;i++)
  21. {
  22. if(n[i]>0)
  23. {
  24. cout << char(i) <<": ";
  25. for(int j=0;j<n[i];j++)
  26. {
  27. cout << positions[i][j] <<" ";
  28. }
  29. cout << endl;
  30. }
  31. }
  32. }
  33.  
  34. int main()
  35. {
  36. string s;
  37.  
  38. cin >> s;
  39.  
  40. findChars(s);
  41.  
  42. return 0;
  43. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement