Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <cmath>
- using namespace std;
- int main(){
- cout << "podaj liczbę dziesiętną" << endl;
- int liczba10;
- cin >> liczba10;
- string liczba3="";
- int c, r;
- c=liczba10;
- do{
- r = c % 3;
- c = c / 3;
- if(r==2){
- liczba3 = liczba3 + '2';
- }
- else if (r==1)
- {
- liczba3 = liczba3 + '1';
- }
- else{
- liczba3 = liczba3 + '0';
- }
- }while(c!=0);
- cout << liczba3 <<endl;
- int n = liczba3.size();
- string liczba3rev;
- for( int i=n-1; i>=0; i-- ){
- liczba3rev = liczba3rev + liczba3 [i];
- }
- cout << liczba3rev << endl;
- system("PAUSE");
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement