Advertisement
Guest User

Untitled

a guest
Nov 19th, 2018
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.62 KB | None | 0 0
  1. #include <iostream>
  2. #include <cmath>
  3. using namespace std;
  4. int main(){
  5.  
  6. cout << "podaj liczbę dziesiętną" << endl;
  7. int liczba10;
  8. cin >> liczba10;
  9. string liczba3="";
  10. int c, r;
  11. c=liczba10;
  12.  
  13. do{
  14. r = c % 3;
  15. c = c / 3;
  16.  
  17. if(r==2){
  18. liczba3 = liczba3 + '2';
  19. }
  20. else if (r==1)
  21. {
  22. liczba3 = liczba3 + '1';
  23. }
  24. else{
  25. liczba3 = liczba3 + '0';
  26. }
  27. }while(c!=0);
  28. cout << liczba3 <<endl;
  29. int n = liczba3.size();
  30. string liczba3rev;
  31. for( int i=n-1; i>=0; i-- ){
  32.  
  33. liczba3rev = liczba3rev + liczba3 [i];
  34. }
  35.  
  36. cout << liczba3rev << endl;
  37.  
  38. system("PAUSE");
  39. return 0;
  40. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement