that_one_nigga_you_k

soma das areas

Nov 12th, 2023 (edited)
115
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.78 KB | None | 0 0
  1. #include <stdio.h>
  2.  
  3. int main() {
  4.     double a, b, C, base, altura;
  5.     double alturatotal = 0;
  6.     double area;
  7.     int n;
  8.     double areatotal;
  9.    
  10.     scanf("%lf %lf %d", &a, &b, &n);
  11.     scanf("%lf", &C);
  12.  
  13.     base = (b - a) / (n );
  14.    
  15.    
  16.       for (int i = 1; i <= n; i++) {
  17.         double x = a + (i) * base; // calculo da fun��p
  18.         altura = x * x;            //altura naquele ponto
  19.         alturatotal += altura;      //soma das alturas
  20.         //a = x;
  21.     }
  22.  
  23.     area = base * alturatotal; //multiplica??o final
  24.     double tolerance = 0; // ou ajuste conforme necess�rio
  25.     if (area > C + tolerance)
  26.         printf("Maior\n");
  27.     else if (area < C - tolerance)
  28.         printf("Menor\n");
  29.     else
  30.         printf("Igual\n");
  31.  
  32.     return 0;
  33. }
  34.  
Add Comment
Please, Sign In to add comment