Advertisement
PiDPC

Untitled

Oct 15th, 2019
107
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.70 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <math.h>
  3.  
  4. /*
  5. Daniel Wasiak
  6. Wzór Herona - Zadanie
  7. */
  8. int main() {
  9.  
  10.     float a, b, c;
  11.  
  12.     printf("Podaj liczbe A: ");
  13.     scanf("%f", &a);
  14.     printf("Podaj liczbe B: ");
  15.     scanf("%f", &b);
  16.     printf("Podaj liczbe C: ");
  17.     scanf("%f", &c);
  18.  
  19.     if(a+b>c && a+c>b && b+c>a) {
  20.         //Mozna stworzyc trojkat z tych bokow
  21.         float p = (a+b+c)/2, surface;
  22.         surface = sqrt( p*(p-a)*(p-b)*(p-c) );
  23.         printf("\nPole powierzchni podanego trojkata to: \n%f jednostek\n", surface);
  24.  
  25.     } else {
  26.         //Taki trokjat nie istnieje
  27.         printf("\nZ podanych bokow nie mozna zbudowac trojkata.\n");
  28.     }
  29.  
  30.     printf("\n");
  31.  
  32.     return 0;
  33. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement