Advertisement
tei123

cockrice

Apr 4th, 2016
225
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.14 KB | None | 0 0
  1. #include <cstdlib>
  2. #include <iostream>
  3. #include <conio.h>
  4. #include "windows.h"
  5. #include <time.h>
  6.  
  7. using namespace std;
  8.  
  9. void menu()
  10. {
  11. cout<<"MENU:"<<endl;
  12. cout<<"1. Kwadrat"<<endl;
  13. cout<<"2. Prostokat"<<endl;
  14. cout<<"3. Trojkat"<<endl;
  15. cout<<"4. Kolo"<<endl;
  16. }
  17.  
  18. int kwad()
  19. {
  20. int a;
  21. cout<<"Wprowadz bok kwadratu: ";
  22. cin>>a;
  23. cout<<"Pole kwadratu: "<<a*a<<endl;
  24. cout<<"Obwod kwadratu: "<<4*a<<endl<<endl;
  25. }
  26.  
  27. int pros()
  28. {
  29. int a, b;
  30. cout<<"Wprowadz pierwszy bok prostokata: ";
  31. cin>>a;
  32. cout<<"Wprowadz drugi bok prostokata: ";
  33. cin>>b;
  34. cout<<"Pole prostokata: "<<a*b<<endl;
  35. cout<<"Obwod Prostokata: "<<(2*a)+(2*b)<<endl<<endl;
  36. }
  37.  
  38. int troj()
  39. {
  40. int a, b, c, d;
  41. cout<<"Wprowadz pierwszy bok trojkata: ";
  42. cin>>a;
  43. cout<<"Wprowadz drugi bok trojkata: ";
  44. cin>>c;
  45. cout<<"Wprowadz trzeci bok trojkata: ";
  46. cin>>d;
  47. cout<<"Wprowadz wysokosc trojkata: ";
  48. cin>>b;
  49. cout<<"Pole trojkata: "<<0.5*a*b<<endl;
  50. cout<<"Obwod trojkata: "<<a+c+d<<endl<<endl;;
  51. }
  52.  
  53. int kolo()
  54. {
  55. int a;
  56. cout<<"Wprowadz promien kola: ";
  57. cin>>a;
  58. cout<<"Pole kola: "<<3.14*a*a<<endl;
  59. cout<<"Obwod kola: "<<2*3.14*a<<endl<<endl;;
  60. }
  61. int main(int argc, char *argv[])
  62. {
  63. char yn;
  64. int opt;
  65. do
  66. {
  67. system("CLS");
  68. menu();
  69. int men = getch();
  70. switch( men )
  71. {
  72. case '1':
  73. system("CLS");
  74. kwad();
  75. break;
  76. case '2':
  77. system("CLS");
  78. pros();
  79. break;
  80. case '3':
  81. system("CLS");
  82. troj();
  83. break;
  84. case '4':
  85. system("CLS");
  86. kolo();
  87. break;
  88. default:
  89. system("CLS");
  90. cout<<"Nie ma takiej opcji!"<<endl;
  91. break;
  92. }
  93. cout<<"Jeszcze raz? (y/n)";
  94. yn=getch();
  95. cout<<endl;
  96. }while(yn!='n');
  97. return 0;
  98. //system("PAUSE");
  99. return EXIT_SUCCESS;
  100. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement