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