Merge pull request #834 from gilssonn/78-sine-wave-C++

C++ Implementation of Sine Wave
This commit is contained in:
Jeff Atwood
2023-02-04 12:01:55 -08:00
committed by GitHub
2 changed files with 24 additions and 0 deletions

View File

@@ -0,0 +1,3 @@
Original source downloaded [from Vintage Basic](http://www.vintage-basic.net/games.html)
Conversion to [C++17](https://en.wikipedia.org/wiki/C%2B%2B17)

View File

@@ -0,0 +1,21 @@
#include <iostream> // std::cout, std::endl
#include <string> // std::string(size_t n, char c)
#include <cmath> // std::sin(double x)
int main()
{
std::cout << std::string(30, ' ') << "SINE WAVE" << std::endl;
std::cout << std::string(15, ' ') << "CREATIVE COMPUTING MORRISTOWN, NEW JERSEY" << std::endl;
std::cout << std::string(5, '\n');
bool b = true;
for (double t = 0.0; t <= 40.0; t += 0.25)
{
int a = int(26 + 25 * std::sin(t));
std::cout << std::string(a, ' ') << (b ? "CREATIVE" : "COMPUTING") << std::endl;
b = !b;
}
return 0;
}