Duotas stačiakampio perimetras P ir plotas S. Raskite stačiakampio kraštines.
Wed Oct 18 2023 20:21:21 GMT+0000 (Coordinated Universal Time)
Saved by
@AdomsNavicki
#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;
}
content_copyCOPY
Comments