1 条题解
-
0
C :
#include<stdio.h> #include<math.h> #define PI 3.14159265; int main() { double r,s; int n,x1,y1,z1,x2,y2,z2; while(scanf("%d",&n)!=EOF) { while(n--) { scanf("%d%d%d%d%d%d",&x1,&y1,&z1,&x2,&y2,&z2); r=sqrt((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2)+(z1-z2)*(z1-z2)); s=4*r*r*r*PI; printf("%.2lf %.2lf\n",r,s/3); } } return 0; }
C++ :
#include <math.h> #include <stdio.h> using namespace std; const double pi = acos(-1.0); int main() { //freopen("test.in", "r", stdin); //freopen("test.out", "w", stdout); int t; scanf("%d", &t); while (t--) { double r; double ax, ay, az, x, y, z; scanf("%lf%lf%lf", &ax, &ay, &az); scanf("%lf%lf%lf", &x, &y, &z); r=sqrt((x-ax)*(x-ax)+(y-ay)*(y-ay)+(z-az)*(z-az)); printf("%.2f %.2f\n", r, 4*pi*r*r*r/3); } return 0; }
Java :
import java.text.DecimalFormat; import java.util.Scanner; public class Main { private static Scanner s = new Scanner (System.in) ; static DecimalFormat df = new DecimalFormat("0.00") ; public static void main(String[] args) { int t = s.nextInt() ; for (int i = 0; i < t; i++) { int x1 = s.nextInt() ; int y1 = s.nextInt() ; int z1 = s.nextInt() ; int x2 = s.nextInt() ; int y2 = s.nextInt() ; int z2 = s.nextInt() ; int r = (x1-x2)*(x1-x2)+(y1-y2)*(y1-y2)+(z1-z2)*(z1-z2) ; double R = Math.sqrt(r) ; double V = 4*Math.PI*R*R*R/3 ; System.out.println(df.format(R)+" "+df.format(V)); } } }
- 1
信息
- ID
- 1375
- 时间
- 1000ms
- 内存
- 32MiB
- 难度
- (无)
- 标签
- 递交数
- 0
- 已通过
- 0
- 上传者