fork download
  1. #include <iostream>
  2. #include <string>
  3.  
  4. using namespace std;
  5.  
  6. int main()
  7. {
  8. int t;
  9. int n[80];
  10. string liczba1, liczba2;
  11.  
  12. cout << "Wejscie:" << endl;
  13.  
  14. cin >> t;
  15.  
  16. for(int i=0; i<t ; i++)
  17. {
  18. cin >> n[i];
  19. }
  20.  
  21. cout << endl << "Wyjscie:" << endl;
  22.  
  23. for(int in=0; in < t; in++)
  24. {
  25. int warunek = 1;
  26. int loop = 0;
  27.  
  28. if(n[in]>=1 && n[in]<=9)
  29. {
  30. cout << n[in] << " 0" <<endl;
  31. }
  32. else
  33. {
  34. while(warunek)
  35. {
  36. liczba1 = to_string(n[in]);
  37.  
  38. int x = liczba1.size();
  39.  
  40. for(int i=1; i < x; i++)
  41. {
  42. if (liczba1[i-1] == liczba1[x-i])
  43. {
  44. cout << n[in] <<" "<< loop <<endl;
  45. warunek = 0;
  46.  
  47. for(int i=0; i < x; i++)
  48. {
  49. liczba1.resize(x-i);
  50. liczba2.resize(x-i);
  51. }
  52. }
  53. else
  54. {
  55. for(int i=1; i <= x; i++)
  56. {
  57. liczba2[i-1] = liczba1[x-i];
  58. }
  59.  
  60. n[in] = n[in] + stoi(liczba2);
  61. loop++;
  62. }
  63. i=x;
  64. }
  65. }
  66. }
  67. }
  68.  
  69. return 0;
  70. }
  71.  
Success #stdin #stdout 0s 15240KB
stdin
Standard input is empty
stdout
Wejscie:

Wyjscie: