-
题目描述:
-
输入球的中心点和球上某一点的坐标,计算球的半径和体积
-
输入:
-
球的中心点和球上某一点的坐标,以如下形式输入:x0 y0 z0 x1 y1 z1
-
输出:
-
输入可能有多组,对于每组输入,输出球的半径和体积,并且结果保留三位小数
-
样例输入:
-
0 0 0 1 1 1
-
样例输出:
-
1.732 21.766
AC1
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
int main(){
double x0,y0,z0;
double x1,y1,z1;
double r,v;
double pi=acos(-1);
while(scanf("%lf %lf %lf %lf %lf %lf",&x0,&y0,&z0,&x1,&y1,&z1) !=EOF ){
r=sqrt((x1-x0)*(x1-x0)+(y1-y0)*(y1-y0)+(z1-z0)*(z1-z0));
v=(4.0/3)*pi*r*r*r;
printf("%.3lf %.3lf\n",r,v);
}
return 0 ;
}
/**************************************************************
Problem: 1068
User: 人气呆毛选手
Language: C
Result: Accepted
Time:10 ms
Memory:912 kb
****************************************************************/
AC2
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
int main(){
double x0,y0,z0;
double x1,y1,z1;
double r,v;
double pi=acos(-1);
while(scanf("%lf %lf %lf %lf %lf %lf",&x0,&y0,&z0,&x1,&y1,&z1) !=EOF ){
r=sqrt(pow(fabs((x1-x0)),2)+pow(fabs((y1-y0)),2)+pow(fabs((z1-z0)),2));
v=(4.0/3)*pi*pow(r,3);
printf("%.3lf %.3lf\n",r,v);
}
return 0 ;
}
/**************************************************************
Problem: 1068
User: 人气呆毛选手
Language: C
Result: Accepted
Time:10 ms
Memory:1004 kb
****************************************************************/