Kassiow

Zamiany liczbowe

May 23rd, 2017
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.87 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. using namespace std;
  4. int cyfry(int);
  5. int main()
  6. {
  7.     int a,p,t=0,q,w,e=0,wynik;
  8.     int tab[100];
  9.     int druga[100];
  10.     cout << "Podaj liczbe dziesietna " << endl;
  11.     cin>>a;
  12.     cout<<" Podaj system zamiany "<<endl;
  13.     cin>>p;
  14.     while(a!=0){
  15.  
  16.  
  17.         tab[t]=a%p;
  18.         a=a/p;
  19.         tab[t++];
  20.     }
  21.  
  22.         for(int k=t-1;k>=0;k--){
  23.             cout<<tab[k];
  24.         }
  25. // drugi program ----------------------------------------------------------
  26.      cout << "Podaj system liczbowy " << endl;
  27.     cin>>q;
  28.     cout<<" Podaj liczbe w tym systemie"<<endl;
  29.     cin>>w;
  30.     cout<<cyfry(w);
  31.     for(int j=cyfry(w);j>0;j--){
  32.         druga[j-e]=w/10;
  33.         e++;
  34.         wynik=q*druga[j];
  35.         druga[j-e]=w%10;
  36.         e++;
  37.  
  38.     }
  39.     return 0;
  40. }
  41. int cyfry(int liczba)
  42. {
  43. int b=1;
  44. while(liczba=liczba/10)b++;
  45. return b;
  46. }
Advertisement
Add Comment
Please, Sign In to add comment