Preview:
#include <iostream>
#include <cmath>

int main() {
    double P, S;

    // Prompt the user for the perimeter and area
    std::cout << "Įveskite stačiakampio perimetrą (P): ";
    std::cin >> P;
    std::cout << "Įveskite stačiakampio plotą (S): ";
    std::cin >> S;

    // Calculate the sides of the rectangle
    double a, b;

    // Calculate a and b using the quadratic formula
    a = (P + sqrt(P * P - 16 * S)) / 4;
    b = (P - sqrt(P * P - 16 * S)) / 4;

    // Display the results
    std::cout << "Stačiakampio kraštinės: a = " << a << ", b = " << b << std::endl;

    return 0;
}
downloadDownload PNG downloadDownload JPEG downloadDownload SVG

Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!

Click to optimize width for Twitter