task 1.1

mail@pastecode.io avatar
unknown
c_cpp
a year ago
539 B
2
Indexable
Never
#define _USE_MATH_DEFINES
#include <iostream>
#include <windows.h>
#include <cmath>

using namespace std;

double calculateY(double x) {
    return abs(cos(2*x));
}

int main() {
    double x;
    HANDLE hCon;
    COORD cPos;
    hCon = GetStdHandle(STD_OUTPUT_HANDLE);

    for (int i = 1; i <= 80; i++) {
        cPos.X = i;

        x = (i-1)*2*M_PI/79.0;
        cPos.Y = trunc(-25+26*calculateY(x));
        
        SetConsoleCursorPosition (hCon, cPos);
        cout << "*";
    }

    system("pause");
}