-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstar parabolla
More file actions
27 lines (23 loc) · 774 Bytes
/
star parabolla
File metadata and controls
27 lines (23 loc) · 774 Bytes
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
#include <iostream>
#include <cmath>
int main() {
const int width = 40; // Width of the output window
const int height = 20; // Height of the output window
// Loop through each row
for (int y = height; y >= -height; --y) {
// Loop through each column
for (int x = -width; x <= width; ++x) {
// Calculate the value of the parabola equation
double value = pow(x / 10.0, 2) - y;
// If the value is close to zero, print an asterisk
if (std::abs(value) < 0.5) {
std::cout << "*";
} else {
std::cout << " ";
}
}
// Move to the next line after printing a row
std::cout << std::endl;
}
return 0;
}