Advertisement
Guest User

Untitled

a guest
Nov 12th, 2018
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 2.31 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <conio.h>
  3. #include <stdlib.h>
  4. #include <math.h>
  5.  
  6. int wyb=0;
  7. float a, b, c, r, pol, h=0.0;
  8. const float PI=3.14;
  9.  
  10. int main()
  11. {
  12.     for(;;){
  13.     printf("MENU GLOWNE: \n");
  14.     printf("1 - Kolo \n");
  15.     printf("2 - Prostokat \n");
  16.     printf("3 - Trojkat \n");
  17.     printf("4 - Trapez \n");
  18.     printf("5 - Kwadrat \n");
  19.     printf("6 - WYJSCIE \n");
  20.  
  21.     printf("Wybierz bryle: \n");
  22.     scanf("%d", &wyb);
  23.  
  24.         switch(wyb){
  25.         case 1:{
  26.                 printf("Podaj : \n");
  27.                 scanf("%f", &r);
  28.                 pol=(r * r * PI);
  29.                 printf("Pole kola o promieniu %.1f wynosi %.1f\n", r, pol);
  30.                 break;
  31.         }
  32.         case 2:{
  33.                 printf("Podaj bok A: \n");
  34.                 scanf("%f", &a);
  35.                 printf("Podaj bok B: \n");
  36.                 scanf("%f", &b);
  37.                 pol=(a * b);
  38.                 printf("Pole prostokata o boku A %.1f i boku B %.1f wynosi %.1f\n", a, b, pol);
  39.                 break;
  40.         }
  41.         case 3:{
  42.                 printf("Podaj bok A: \n");
  43.                 scanf("%f", &a);
  44.                 printf("Podaj wysokosc: \n");
  45.                 scanf("%f", &h);
  46.                 pol=(a * h)/ 2;
  47.                 printf("Pole trojkata o boku A %.1f i wysokosci %.1f wynosi %.1f\n", a, h, pol);
  48.                 break;
  49.         }
  50.         case 4:{
  51.                 printf("Podaj bok A: \n");
  52.                 scanf("%f", &a);
  53.                 printf("Podaj bok B: \n");
  54.                 scanf("%f", &b);
  55.                 printf("Podaj wysokosc: \n");
  56.                 scanf("%f", &h);
  57.                 pol=(a + b)*h / 2;
  58.                 printf("Pole trapezu o boku A %.1f boku B %.1f i wysokosc %.1f wynosi %.1f\n", a, b,h,pol);
  59.                 break;
  60.         }
  61.         case 5:{
  62.                 if(wyb == 5){
  63.                     printf("Podaj bok A: \n");
  64.                     scanf("%f", &a);
  65.                     pol=(a*a);
  66.                     printf("Pole kwadratu wynosi %.1f\n", pol);
  67.                     break;
  68.  
  69.                 }
  70.         }
  71.  
  72.         case 6:{
  73.                 exit(0);
  74.         }
  75.         default:{
  76.                 printf("Zly wybor.\n");
  77.                 break;
  78.         }
  79.         }
  80.         getchar();getchar();
  81.         system("cls");
  82.     }
  83.  
  84.     return 0;
  85. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement