Advertisement
rakoczyn

Przeliczanie_systemow_liczbowych

Oct 19th, 2011
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.82 KB | None | 0 0
  1. #include <cstdlib>
  2. #include <iostream>
  3.  
  4. using namespace std;
  5. int tablica[15];
  6. int liczba, reszta;
  7.  
  8. void zerowanie ()
  9. {
  10.     int a;
  11.     for (a=0; a<=15; a++)
  12.     {
  13.         tablica[a]=0;
  14.     }
  15. }
  16.  
  17. void wprlicz ()
  18. {
  19.     do
  20.     {
  21.         cout<<"Wprowadz liczbe z zakresu 1-10000" <<endl;
  22.         cin >> liczba;
  23.     }
  24.     while (liczba>10000);
  25. }
  26.  
  27. void liczenie ()
  28. {
  29.     int n;
  30.  
  31.     cout << "podaj podstawe";
  32.     cin>>n;
  33.     int z=0;
  34.    
  35.     do
  36.     {
  37.         reszta = liczba%n;
  38.         liczba = liczba/n;
  39.         tablica[z]=reszta;
  40.         z=z+1;
  41.     }
  42.     while (liczba!=0);    
  43.    
  44.     if (tablica[z]==0)
  45.     {    
  46.         for (z=z-1; z>=0; z--)
  47.         {
  48.             cout<<tablica[z];
  49.         }
  50.     }
  51.     else
  52.     {  
  53.         for (z; z>=0; z--)
  54.         {
  55.             cout<<tablica[z];
  56.         }
  57.     }
  58. }
  59.  
  60. int main(int argc, char *argv[])
  61. {  
  62.     zerowanie ();
  63.     wprlicz ();
  64.     liczenie ();
  65.     system("PAUSE");
  66.     return EXIT_SUCCESS;
  67. }
  68.  
  69.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement