Advertisement
Reykez

1312

Feb 16th, 2019
106
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.57 KB | None | 0 0
  1. #include <iostream>
  2. #include <stdio.h>
  3. #include <cstdlib>
  4. #include <conio.h>
  5. #include <math.h>
  6.  
  7. using namespace std;
  8.  
  9. float x, y;
  10. char wybor;
  11.  
  12. int potega(int px, int py) {
  13. int pz;
  14. for(int i=2; i < py; i++) {
  15. px=px*px;
  16. }
  17. return px;
  18. }
  19.  
  20. int main()
  21. {
  22. for(;;)
  23. {
  24.  
  25. cout << "Podaj 1 liczbe: "<<endl;
  26. cin >>x;
  27.  
  28. cout<<"Podaj 2 liczbe: "<<endl;
  29. cin>>y;
  30.  
  31. cout<<endl;
  32. cout<<"MENU GLOWNE"<<endl;
  33. cout<<"--------------"<<endl;
  34. cout<<"1. Dodawanie"<<endl;
  35. cout<<"2. Odejmowanie"<<endl;
  36. cout<<"3. Mnozenie"<<endl;
  37. cout<<"4. Dzielenie"<<endl;
  38. cout<<"5. Potegowanie"<<endl;
  39. cout<<"6. Wyjscie"<<endl;
  40. cout<<"--------------"<<endl;
  41.  
  42. cout<<endl;
  43. wybor=getch();
  44.  
  45. switch (wybor)
  46. {
  47. case '1':
  48. cout<<"Suma = "<<x+y;
  49. break;
  50.  
  51. case '2':
  52. cout<<"Roznica = "<<x-y;
  53. break;
  54.  
  55. case '3':
  56. cout<<"Iloczyn = "<<x*y;
  57. break;
  58.  
  59. case '4':
  60. if (y==0) cout<< "Nie dzieli sie przez 0 :)"; // super, Åže pamietasz o blokowaniu bugowania ;)
  61. else cout<<"Iloraz = "<< x/y;
  62. break;
  63.  
  64. case '5':
  65. cout<<"Potega = "<< potega (x,y);
  66. break;
  67.  
  68. case '6':
  69. exit(0);
  70. break;
  71.  
  72. default: cout<<"Nie ma takiej opcji w menu!";
  73. } // case end
  74.  
  75. getchar();getchar();
  76. system("cls");
  77.  
  78. } // for end
  79. return 0;
  80. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement