#include <iostream>using std::cout;using std::cin;using std::endl;#include <cmath>using std::pow;using std::sqrt;double vpisannayaOkryzhnost(double);double opisannayaOkryzhnost(double);int main(){ double perimeter; cout << "Vvedite perimeter: "; cin >> perimeter; cout << "r vpisannoi okruzhnosti = " << vpisannayaOkryzhnost(perimeter) << endl; cout << "R opisannoi okruzhnosti = " << opisannayaOkryzhnost(perimeter) << endl; cin.get(); return 0;}double vpisannayaOkryzhnost(double perimeter){ double a = perimeter / 4; return (a / 2);}double opisannayaOkryzhnost(double perimeter){ double a = perimeter / 4; return (sqrt(2) / 2 * a);}
На Гэ-паскале можно написать так:
program math;var perimeter, a: real;begin write('Vvedite perimeter: '); read(perimeter); a := perimeter / 4; writeln('r vpisannoi okruzhnosti = ', a / 2:0:2); writeln('R opisannoi okruzhnosti = ', sqrt(2) / 2 * a:0:2); readln(); readln();end.
#include <iostream>
using std::cout;
using std::cin;
using std::endl;
#include <cmath>
using std::pow;
using std::sqrt;
double vpisannayaOkryzhnost(double);
double opisannayaOkryzhnost(double);
int main()
{
double perimeter;
cout << "Vvedite perimeter: ";
cin >> perimeter;
cout << "r vpisannoi okruzhnosti = " << vpisannayaOkryzhnost(perimeter) << endl;
cout << "R opisannoi okruzhnosti = " << opisannayaOkryzhnost(perimeter) << endl;
cin.get();
return 0;
}
double vpisannayaOkryzhnost(double perimeter)
{
double a = perimeter / 4;
return (a / 2);
}
double opisannayaOkryzhnost(double perimeter)
{
double a = perimeter / 4;
return (sqrt(2) / 2 * a);
}
На Гэ-паскале можно написать так:
program math;
var perimeter, a: real;
begin
write('Vvedite perimeter: ');
read(perimeter);
a := perimeter / 4;
writeln('r vpisannoi okruzhnosti = ', a / 2:0:2);
writeln('R opisannoi okruzhnosti = ', sqrt(2) / 2 * a:0:2);
readln();
readln();
end.