Advertisement
Guest User

Untitled

a guest
Dec 13th, 2018
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.90 KB | None | 0 0
  1. #include <iostream>
  2. #include <string>
  3. using namespace std;
  4.  
  5. void zadanie1()
  6. {
  7. double figura[2];
  8. double wynik[1];
  9. cout<<"Oblicz :"<<endl<<"[1] Pole"<<endl<<"[2] Obwod"<<endl;
  10. int x;
  11. cin>>x;
  12.  
  13. switch(x)
  14. {
  15. case 1:
  16. cout<<"Wybierz figure"<<endl<<"[1] Kwadrat"<<endl<<"[2] Prostokat"<<endl<<"[3] Kolo"<<endl;
  17. int y;
  18. cin>>y;
  19. switch(y)
  20. {
  21. case 1:
  22. cout<<"Kwadrat"<<endl<<"\t Podaj wymiar boku: "<<endl;
  23. cin>>figura[0];
  24. wynik[0]=(figura[0]*figura[0]);
  25. cout<<"Pole kwadratu o wymiarze boku "<<figura[0]<<" wynosi "<<wynik[0]<<endl;
  26. break;
  27. case 2:
  28. cout<<".Prostokat"<<endl<<"\t Podaj wymiary jednego boku: "<<endl;
  29. cin>>figura[0];
  30. cout<<"\t Podaj wymiary drugiego boku: "<<endl;
  31. cin>>figura[1];
  32. wynik[0]=(figura[0]*figura[1]);
  33. cout<<"Pole prostokotu o wymiarach "<<figura[0]<<" na "<<figura[1]<<" wynosi "<<wynik[0]<<endl;
  34. break;
  35. case 3:
  36. cout<<"Kolo"<<endl<<"\t Podaj dlugosc promienia: "<<endl;
  37. cin>>figura[0];
  38. figura[1]=(3.14);
  39. wynik[0]=(figura[1]*figura[0]*figura[0]);
  40. cout<<"Pole kola o promieniu "<<figura[0]<<" wynosi "<<wynik[0]<<endl;
  41. break;
  42. default:
  43. cout<<"nie ma takiej figury"<<endl;
  44. break;
  45. }
  46.  
  47. break;
  48.  
  49. case 2:
  50. cout<<"Wybierz figure"<<endl<<"[1] Kwadrat"<<endl<<"[2] Prostokat"<<endl<<"[3] Kolo"<<endl;
  51. int h;
  52. cin>>h;
  53. switch(h)
  54. {
  55. case 1:
  56. cout<<"Kwadrat"<<endl<<"\t Podaj wymiary boku "<<endl;
  57. cin>>figura[0];
  58. wynik[0]=(figura[0]*4);
  59. cout<<"Obwod kwadratu o boku "<<figura[0]<<"wynosi "<<wynik[0]<<endl;
  60. break;
  61. case 2:
  62. cout<<"Prostokat"<<endl<<"\t Podaj wymiary jednego boku: "<<endl;
  63. cin>>figura[0];
  64. cout<<"\t Podaj wymiary drugiego boku"<<endl;
  65. cin>>figura[1];
  66. wynik[0]=((figura[0]+figura[1])*2);
  67. cout<<"Obwod prostokotu o wymiarach "<<figura[0]<<" na "<<figura[1]<<" wynosi "<<wynik[0]<<endl;
  68. break;
  69. case 3:
  70. cout<<"Kolo"<<endl<<"\t Podaj dlugosc promienia: "<<endl;
  71. cin>>figura[0];
  72. figura[1]=(3.14);
  73. wynik[0]=(figura[1]*figura[0]*2);
  74. cout<<"Obwod kola o promieniu "<<figura[0]<<" wynosi "<<wynik[0]<<endl;
  75. break;
  76. default:
  77. cout<<"nie ma takiej figury"<<endl;
  78. break;
  79.  
  80. }
  81. break;
  82. }
  83.  
  84.  
  85. }
  86. //---------------------------------------------------------
  87.  
  88.  
  89. void zadanie2()
  90. {
  91.  
  92. int A=5;
  93. int B=6;
  94. int tab[A][B];
  95.  
  96. for (int a = 0; a < A; a++)
  97. {
  98. for (int b = 0; b < B; b++)
  99. {
  100.  
  101. cout << '*';
  102.  
  103. }
  104. cout << "\n";
  105. }
  106.  
  107. }
  108. //------------------------------------------------------------
  109.  
  110.  
  111. void zadanie3()
  112. {
  113. double tab[3];
  114. double a,b,c;
  115. cout<<"Podaj trzy boki trojkata"<<endl;
  116. cin>>tab[0];
  117. cin>>tab[1];
  118. cin>>tab[2];
  119. a=(tab[0] * tab[0]);
  120. b=(tab[1] * tab[1]);
  121. c=(tab[2] * tab[2]);
  122.  
  123. if((c==(a+b)) || (a==(c+b)) || (b==(a+c)))
  124. {cout<<"Da sie stworzyc trojkat prostokatny"<<endl;}
  125. else {cout<<"Nie da sie stowrzyyc trojkata prostokatnego"<<endl;}
  126.  
  127.  
  128. }
  129. //------------------------------------------------------------
  130.  
  131.  
  132. int main() {
  133. while(true)
  134. {
  135.  
  136. cout<<"Wybierz zadanie:"<<endl;
  137. cout<<"1. Zadanie 1"<<endl;
  138. cout<<"2. Zadanie 2"<<endl;
  139. cout<<"3. Zadanie 3"<<endl;
  140.  
  141. char wybor;
  142. cin>>wybor;
  143.  
  144. if (wybor=='q' || wybor=='Q')
  145. exit(0);
  146. else
  147. {
  148. switch(wybor)
  149. {
  150. case '1': zadanie1(); break;
  151. case '2': zadanie2(); break;
  152. case '3': zadanie3(); break;
  153. }
  154. }
  155.  
  156. cout<<endl;
  157.  
  158. }
  159. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement