Untitled

mail@pastecode.io avatar
unknown
plain_text
2 years ago
481 B
7
Indexable
Never
#include <iostream>
#include <math.h>

using namespace std;

int main()
{
    float h = 0.1;
    float a = 0.75;
    float b = 1.19;
    float c = -2.5;

    for (float x = 0; x < 1; x += h)
    {
        float y = 0;
        if (x < 0.5)
        {
            y = a * x + b * cos(x);
        }
        else if (x >= 0.5 && x <= 1)
        {
            y = b * pow(x, 2) + c * sin(2 * x);
        }

        cout << "\nx = " << x << " y = " << y;
    }
}