-
-
Save vocalinternet/ae8e39a7dbcf3c79ee784539063a1c1a to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <cmath> | |
#include <iostream> | |
#include <string> | |
#include <vector> | |
int main() | |
{ | |
int size = 80, height = 21; | |
// Start with an empty chart (lots of spaces and a line in the middle) | |
std::vector<std::string> chart(height, std::string(size, ' ')); | |
chart[height/2] = std::string(size, '-'); | |
// Then just put x-es where the function should be plotted | |
for(int i = 0; i < size; i++) { | |
chart[static_cast<int>(std::round(10 * std::sin(i / 4.5) + 10))][i] = '*'; | |
} | |
// and print the whole shebang | |
for(auto &&s : chart) { | |
std::cout << s << '\n'; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment