Advertisement
Guest User

Untitled

a guest
Feb 17th, 2019
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.37 KB | None | 0 0
  1. #include <iostream>
  2. #include <cstdlib>
  3. #include <math.h>
  4. #include <conio.h>
  5. using namespace std;
  6.  
  7. double a,b,c,d,w;
  8. int i,j,z;
  9. int main(){
  10. do{
  11. system("cls");
  12. cout<<"*-*-*-*-*- Program -*-*-*-*-*"<<endl;
  13. cout<<"Pole kola [1]"<<endl;
  14. cout<<"Pierwiastek z odejmowania [2]"<<endl;
  15. cout<<"Petla for [3]"<<endl;
  16. cout<<"Koniec [0]"<<endl;
  17. cin>>z;
  18. system("cls");
  19. switch(z){
  20. case 1:
  21. cout<<"*-*-*-*-*- Pole kola -*-*-*-*-*"<<endl;
  22. cout<<"Wpisz promien: "<<endl;
  23. cin>>a;
  24. if(a>0){
  25. w=M_PI*pow(a,2);
  26. cout<<"Pole kola o promieniu: "<<a<<" wynosi: "<<w<<endl;
  27. }
  28. else{
  29. cout<<"Promien musi byc wiekszy od zera"<<endl;
  30. }
  31. getch();
  32. break;
  33.  
  34. case 2:
  35. cout<<"Pierwiastek z odejmowania dwoch liczb"<<endl;
  36. cout<<"Wpisz pierwsza liczbe: "<<endl;
  37. cin>>a;
  38. cout<<"Wpisz druga liczbe: "<<endl;
  39. cin>>b;
  40. w=a-b;
  41. cout<<a<<"-"<<b<<"="<<w<<endl;
  42. if(w>=0){
  43. c=sqrt(w);
  44. cout<<"Pierwiastek z "<<w<<"="<<c<<endl;
  45. }
  46. else{
  47. cout<<"Brak pierwiastka z liczby ujemnej"<<endl;
  48. }
  49.  
  50. getch();
  51. break;
  52.  
  53. case 3:
  54. cout<<"Petla for"<<endl;
  55. cout<<"Wpisz a: "<<endl;
  56. cin>>a;
  57. cout<<"Wpisz b: "<<endl;
  58. cin>>b;
  59. if(a>b){
  60. for(i=b;i<=a;i++){
  61. cout<<"i = "<<i<<endl;
  62. }
  63. }
  64. else{
  65. for(i=a;i<=b;i++){
  66. cout<<"i = "<<i<<endl;
  67. }
  68. }
  69. getch();
  70. break;
  71.  
  72. case 0:
  73. cout<<"Koniec"<<endl;
  74. break;
  75.  
  76. default:
  77. cout<<"Zly operator"<<endl;
  78. getch();
  79. break;
  80. }
  81. }while(z!=0);
  82. return 0;
  83. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement