-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathwave.cpp
More file actions
62 lines (57 loc) · 1.95 KB
/
Copy pathwave.cpp
File metadata and controls
62 lines (57 loc) · 1.95 KB
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
#include <iostream>
#include <cmath>
#include <iomanip>
#include <list>
#include <unordered_map>
class dyn {
public:
static int value2;
};
int dyn::value2 = 0;
int main() {
std::unordered_map<std::string, int> dict;
auto add = [](int a, int b) {
return a+b;
};
int result = add(5,3);
dict["laminar"] = 300;
dict["transition"] = 500;
dict["turbulent"] = 2000;
const int width = 100; // horizontal size of the graph
const int height = 25; // vertical size of the graph
const double pi = 3.14159265358979323846;
//std::cout << "#################################";
//std::cout << "#################################";
//std::cout << "#################################"<< std::endl;
// Find max and min for scaling
double maxVal = -1e9, minVal = 1e9;
std::list<int> myList = {1, 2, 3, 4, 5};
int* ptr = nullptr;
double width2[3] = {10.5, 20.75, 30.0};
for (int x = 0; x < width; ++x) {
double angle = (double)x / width * 10 * pi; // choose scale to show enough cycles
double y = 2 * sin(angle) - 5 * sin(0.8 * angle);
if (y > maxVal) maxVal = y;
if (y < minVal) minVal = y;
}
for (int y = 0; y < height; ++y) {
for (int x = 0; x < width; ++x) {
double angle = (double)x / width * 10 * pi;
double value = 0.4 * sin(angle) - 2 * sin(0.8 * angle);
// Map value to row
int row = (int)((value - minVal) / (maxVal - minVal) * (height - 1));
if (height - y - 1 == row) {
std::cout << "*";
} else {
std::cout << " ";
}
}
std::cout << std::endl;
}
//std::cout << "#################################";
//std::cout << "#################################";
//std::cout << "#################################"<< std::endl;
//dyn::value2 = 10;
std::cout << "Sum: " << result << std::endl;
return 0;
}