Advertisement
rootuss

systemy hex-dec-oct

Nov 26th, 2016
246
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.33 KB | None | 0 0
  1. #include <iostream>
  2. #include <iomanip>
  3. #include <cstdlib>
  4.  
  5. using namespace std;
  6.  
  7. int main()
  8. {
  9.     int a,b, suma;
  10.     int sz;
  11.     cout << "Oblicznie sumy liczb" << endl;
  12.     cout<<endl;
  13.  
  14.     cout << "podaj a i b" << endl;
  15.     cin>>a>>b;
  16.     cout << "podaj szerokosc pol: " << endl;
  17.     cin>>sz;
  18.  
  19.     system("cls");
  20.     suma=a+b;
  21.  
  22.  
  23.     cout<<"system dziesietny:"<<endl;
  24.     cout << "Oblicznie sumy liczb" << endl;
  25.     cout << "a= "<<setfill(' ')<<setw(sz)<<a<<endl;
  26.     cout <<"b= "<<setfill(' ')<<setw(sz)<<b<<endl;
  27.  
  28.     cout <<setfill('-')<<setw(sz+4)<<" "<<endl;
  29.     cout<<"s= " <<setfill(' ')<<setw(sz)<<suma<<endl;
  30.     cout<<endl<<endl;
  31.  
  32.     cout<<"system heksadecymalny: "<<endl;
  33.     cout << "Oblicznie sumy liczb" << endl;
  34.     cout << "a= "<<hex<<setfill(' ')<<setw(sz)<<a<<endl;
  35.     cout <<"b= "<<hex<<setfill(' ')<<setw(sz)<<b<<endl;
  36.  
  37.     cout <<setfill('-')<<setw(sz+4)<<" "<<endl;
  38.     cout<<"s= " <<hex<<setfill(' ')<<setw(sz)<<suma<<endl;
  39.     cout<<endl<<endl;
  40.  
  41.  
  42.     cout<<"system oktalny:"<<endl;
  43.     cout << "Oblicznie sumy liczb" << endl;
  44.     cout << "a= "<<oct<<setfill(' ')<<setw(sz)<<a<<endl;
  45.     cout <<"b= "<<oct<<setfill(' ')<<setw(sz)<<b<<endl;
  46.  
  47.     cout <<setfill('-')<<setw(sz+4)<<" "<<endl;
  48.     cout<<"s= " <<oct<<setfill(' ')<<setw(sz)<<suma<<endl;
  49.     cout<<endl<<endl;
  50.  
  51.  
  52.     return 0;
  53. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement