File tree Expand file tree Collapse file tree 2 files changed +48
-38
lines changed
Expand file tree Collapse file tree 2 files changed +48
-38
lines changed Original file line number Diff line number Diff line change 1+ #include <stdio.h>
2+ #include <math.h>
3+
4+ typedef struct {
5+ double r1 ;
6+ double r2 ;
7+ int exists ;
8+ } auxiliary ;
9+
10+ auxiliary support (double A , double B , double C )
11+ {
12+ auxiliary result ;
13+ double delta = (B * B ) - 4 * A * C ;
14+
15+ if (delta >= 0 && A != 0 ) {
16+ result .r1 = ((B * -1 ) + sqrt (delta )) / (2 * A );
17+ result .r2 = ((B * -1 ) - sqrt (delta )) / (2 * A );
18+ result .exists = 1 ;
19+ } else {
20+ result .exists = 0 ;
21+ }
22+
23+ return result ;
24+ }
25+
26+ void print (auxiliary result )
27+ {
28+ if (result .exists ) {
29+ printf ("R1 = %.5lf\n" , result .r1 );
30+ printf ("R2 = %.5lf\n" , result .r2 );
31+ } else {
32+ printf ("Impossivel calcular\n" );
33+ }
34+ }
35+
36+ int main ()
37+ {
38+ double A , B , C ;
39+ auxiliary result ;
40+
41+ scanf ("%lf %lf %lf" , & A , & B , & C );
42+
43+ result = support (A , B , C );
44+ print (result );
45+
46+ return 0 ;
47+ }
48+
Load Diff This file was deleted.
You can’t perform that action at this time.
0 commit comments