1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
|
#include <iostream>
#include <cmath>
#pragma GCC diagnostic ignored "-Wdiv-by-zero"
using namespace std;
void ex0() {
int a;
cin >> a;
// Please, don't do this, it's really ugly
if (a / 100 > 0)
cout << (a / 100) << " * 100" << (((a %= 100) > 0) ? " + " : "");
if (a / 50 > 0)
cout << (a / 50) << " * 50" << (((a %= 50) > 0) ? " + " : "");
if (a / 20 > 0)
cout << (a / 20) << " * 20" << (((a %= 20) > 0) ? " + " : "");
if (a / 10 > 0)
cout << (a / 10) << " * 10" << (((a %= 10) > 0) ? " + " : "");
if (a / 5 > 0)
cout << (a / 5) << " * 5" << (((a %= 5) > 0) ? " + " : "");
if (a / 2 > 0)
cout << (a / 2) << " * 2" << (((a %= 2) > 0) ? " + " : "");
if (a > 0)
cout << a << " * 1";
}
void ex1() {
int a;
cin >> a;
switch (a) {
case 1: cout << "January"; break;
case 2: cout << "February"; break;
case 3: cout << "March"; break;
case 4: cout << "April"; break;
case 5: cout << "May"; break;
case 6: cout << "June"; break;
case 7: cout << "July"; break;
case 8: cout << "August"; break;
case 9: cout << "September"; break;
case 10: cout << "October"; break;
case 11: cout << "November"; break;
case 12: cout << "December"; break;
}
}
void ex2() {
int a;
cin >> a;
if (a >= 160) cout << 700;
else if (a >= 130) cout << 350;
else if (a >= 110) cout << 150;
else if (a >= 90) cout << 50;
else if (a >= 70) cout << 20;
else cout << 0;
}
void ex3() {
int a, b, c;
cin >> a >> b >> c;
if (a < b && a < c)
cout << a << " " << ((b < c) ? b : c) << " " << ((c > b) ? c : b);
else if (b < a && b < c)
cout << b << " " << ((a < c) ? a : c) << " " << ((c > a) ? c : a);
else
cout << c << " " << ((b < a) ? b : a) << " " << ((a > b) ? a : b);
}
void ex4() {
int x1, y1, x2, y2, x, y;
cin >> x1 >> y1 >> x2 >> y2 >> x >> y;
// Again, this is very ugly
cout << (( ((x > x1 && x < x2) || (x > x2 && x < x1)) && ((y > y1 && y < y2) || (y > y2 && y < y1)) ) ? "true" : "false");
}
void ex5() {
cout << "Will output 26, since = returns a reference and at the end it evaluates to c + c." << endl;
int c = 5;
int d = (c += 3) + (c += 5);
cout << d;
}
void ex6() {
cout << "Will output 0, = evaluates from the right to the left, so c becomes 0 and we have 0 + 0." << endl;
int c = 5;
if (c += c -= 5)
cout << (c *= 10);
else
cout << c;
}
void ex7() {
cout << "Will output nothing, since you cannot divide by 0" << endl;
int c = 5;
cout << ((c == 6) || (c / 0));
}
void ex8() {
cout << "Will output 0, since comparison is lazy and when it evaluates c == 6 as false, it just returns" << endl;
int c = 5;
cout << ((c == 6) && (c / 0));
}
void ex9() {
cout << "Will output 16 1, because = returns a reference, which is practically a number, that is more than 0 so it evaluates as true" << endl;
int c = 5;
double e = 0;
cout << ((c = 6) && (e = 1));
cout << c << " " << e;
}
void ex10() {
double a, b, c;
cin >> a >> b >> c;
// Unfinished
double d = b * b - 4 * a * c;
if (d < 0) {
cout << "No real root." << endl;
} else if (d == 0) {
cout << 0;
} else {
d = sqrt(d);
cout << (-b + d) / (2 * a) << " " << (-b - d) / 2;
}
}
int main() {
ex10();
}
|