fork(4) download
  1. #include <iostream>
  2. using namespace std;
  3. string int_to_string(int liczba)
  4. {
  5. string zwracany;
  6. if(liczba<10)
  7. zwracany = char(liczba+48);
  8. else if(liczba>=10 && liczba<100)
  9. {
  10. string pomocniczy;
  11. zwracany = char(((liczba/10)%10)+48);
  12. pomocniczy = char((liczba%10)+48);
  13. zwracany += pomocniczy;
  14. }
  15. else
  16. {
  17. return "Jestesmy poza zakresem funkcji...";
  18. }
  19. return zwracany;
  20. }
  21. int main()
  22. {
  23. int testAmount;
  24. cin>>testAmount;
  25. string slowa[testAmount];
  26. for(int i = 0 ; i<testAmount ; i++)
  27. {
  28. cin.clear();
  29. cin.sync();
  30. getline(cin,slowa[i]);
  31. }
  32. //65-90
  33. for(int a = 0 ; a<testAmount ; a++)
  34. {
  35. for(int i = 65 ; i<91 ; i++)
  36. {
  37. size_t found = string::npos, found2 = string::npos;
  38. int licznik = 0;
  39. string pomoc;
  40. pomoc = char(i);
  41. found = slowa[a].find(pomoc);
  42. if(found!=string::npos)
  43. {
  44. found2 = found;
  45. licznik++;
  46. while(found!=string::npos)
  47. {
  48. found = slowa[a].find(pomoc, found+1);
  49. if(found!=string::npos) licznik++;
  50. }
  51. }
  52. if(licznik>2)
  53. {
  54. slowa[a].erase(found2+1,licznik-1);
  55. slowa[a].insert(found2+1,int_to_string(licznik));
  56. }
  57. }
  58. cout<<slowa[a]<<endl;
  59. }
  60. return 0;
  61. }
Success #stdin #stdout 0s 3476KB
stdin
1
CC
stdout