Advertisement
MeehoweCK

Untitled

Apr 29th, 2021
724
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.51 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. string odwroc(string tekst)
  6. {
  7.     string wynik = "";
  8.     for(int i = tekst.size() - 1; i >= 0; --i)
  9.         wynik += tekst[i];
  10.     return wynik;
  11. }
  12.  
  13. string konwersja_int_string(unsigned liczba)
  14. {
  15.     string wynik = "";
  16.     while(liczba > 0)
  17.     {
  18.         wynik += static_cast<char>(48 + liczba % 10);
  19.         liczba /= 10;
  20.     }
  21.     return odwroc(wynik);
  22. }
  23.  
  24. int main()
  25. {
  26.     int n = 6823;
  27.     cout << konwersja_int_string(n) << endl;
  28.     return 0;
  29. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement