Advertisement
xerpi

2n grau

Aug 16th, 2013
145
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 1.20 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <math.h>
  3.  
  4.  
  5. void Dick()
  6. {
  7.     float a, b, c;
  8.     printf("introduce a: ");
  9.     scanf("%f", &a);
  10.     printf("introduce b: ");
  11.     scanf("%f", &b);
  12.     printf("introduce c: ");
  13.     scanf("%f", &c);
  14.  
  15.     if (b == 0 && c == 0){
  16.         printf("the solution is 0 biatch");
  17.     } else {
  18.         if (a==0) {
  19.             printf ("matherror");
  20.         } else {
  21.  
  22.             float indadick = b*b - 4*a*c;
  23.  
  24.             if (indadick < 0) {
  25.                 printf("SI");
  26.             } else {
  27.                 printf("SCD\n");
  28.                 float indapussy = sqrtf(indadick);
  29.  
  30.                 float indaass_1 = -b + indapussy;
  31.                 float indaass_2 = -b - indapussy;
  32.  
  33.                 float indaass_solution_1 = indaass_1 / (2.0f*a);
  34.                 float indaass_solution_2 = indaass_2 / (2.0f*a);
  35.                 if (indaass_solution_1 == indaass_solution_2){
  36.                     printf ("only one solution : %f" , indaass_solution_1);
  37.                 } else {
  38.                     printf ("solution 1: %f\nsolution 2: %f", indaass_solution_1, indaass_solution_2);
  39.                 }
  40.             }
  41.         }
  42.     }
  43. }
  44.  
  45. int main()
  46. {
  47.     Dick();
  48.  
  49.     return 0;
  50. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement