/
someNetUser
/
CppLabs
Обзор
Документация
Войти
/
someNetUser
/
CppLabs
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
CI/CD
Аналитика
Безопасность
master
0053.cpp
28 строк
1006 B
someNetUser
create 0053.cpp
08 дек 2025, 18:26
08 дек 2025, 18:26
160b032
Код
Авторство
О чём код?
#include <cmath> void GetInput(double& rA, double& thetaA, double& phiA, double& rB, double& thetaB, double& phiB); void PutOutput(double R); void SphericalToCartesian(double r, double theta, double phi, double& x, double& y, double& z) { x = r * sin(theta) * cos(phi); y = r * sin(theta) * sin(phi); z = r * cos(theta); } double Distance(double xA, double yA, double zA, double xB, double yB, double zB) { return sqrt(pow(xB - xA, 2) + pow(yB - yA, 2) + pow(zB - zA, 2)); } void ComputeR(double rA, double thetaA, double phiA, double rB, double thetaB, double phiB, double& R) { double xA, yA, zA, xB, yB, zB; SphericalToCartesian(rA, thetaA, phiA, xA, yA, zA); SphericalToCartesian(rB, thetaB, phiB, xB, yB, zB); R = Distance(xA, yA, zA, xB, yB, zB); } void CalcR() { double rA, thetaA, phiA, rB, thetaB, phiB, R; GetInput(rA, thetaA, phiA, rB, thetaB, phiB); ComputeR(rA, thetaA, phiA, rB, thetaB, phiB, R); PutOutput(R); }