Facebook
From Adrian, 3 Years ago, written in Plain Text.
Embed
Download Paste or View Raw
Hits: 121
  1. #include<iostream>
  2.  
  3. using namespace std;
  4.  
  5.  
  6. int reszta;
  7. int binary[100];
  8. int i=0;
  9. int wybor;
  10. int x;
  11.  
  12.  
  13.  
  14. int binarny(x)
  15. {
  16.                 while(x>0)
  17.                 {
  18.                        
  19.                         x = x/2;
  20.                         reszta = x%2;
  21.                         i++;
  22.                         binary[i-1] = reszta;
  23.                        
  24.                         cout<< binary[i-1];
  25.                 }
  26.                
  27. }
  28.  
  29.         int main()
  30.         {
  31.        
  32.                         cout<<"Co chcesz zrobic?  1 - binarny, 2 - szesnastkowy"<<endl;
  33.                         cin>> wybor;
  34.                        
  35.                        
  36.                         switch(wybor)
  37.                 {
  38.                         case 1:
  39.  
  40.                         cout<<binarny(x)<<endl;
  41.                                
  42.                         break;
  43.                        
  44.                         case 2:
  45.                                 // tu bedzie przeksztalcenie na system szesnastkowy
  46.                        
  47.                 }
  48.                        
  49.        
  50.  
  51.        
  52.  
  53.         }