【清华大学考研机试题】球的半径和体积

版权声明:假装有个原创声明……虽然少许博文不属于完全原创,但也是自己辛辛苦苦总结的,转载请注明出处,感谢! https://blog.csdn.net/m0_37454852/article/details/88314811

原题链接

#include <algorithm>
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
using namespace std;

const double PI = acos(-1);
int xa, ya, za, xb, yb, zb;

int main()
{
    while(scanf("%d %d %d %d %d %d", &xa, &ya, &za, &xb, &yb, &zb) != EOF)
    {
        double R = sqrt( pow(1.0*abs(xa-xb), 2) + pow(1.0*abs(ya-yb), 2) + pow(1.0*abs(za-zb), 2) );
        printf("%.3f %.3f\n", R, PI*pow(R, 3)*4/3.0);
    }
    return 0;
}

猜你喜欢

转载自blog.csdn.net/m0_37454852/article/details/88314811