import java.lang.Math; import java.util.Scanner; public class Main{ public static void main(String[] args){ Scanner in=new Scanner(System.in); while(in.hasNext()){ double x0=in.nextFloat(); double y0=in.nextFloat(); double z0=in.nextFloat(); double x1=in.nextFloat(); double y1=in.nextFloat(); double z1=in.nextFloat(); //注意要在循环输入语句中输出结果 //注意输入格式哟 System.out.printf("%.3f",getRadius(x0,y0,z0,x1,y1,z1)); System.out.print(" "); System.out.printf("%.3f",getVolume(x0,y0,z0,x1,y1,z1)); System.out.println(); } in.close(); } //计算半径的方法,写的详细了点,快的话,可以直接return表达式 public static double getRadius(double x0,double y0,double z0,double x1,double y1,double z1){ double radius=0; double radiusSquare=0; radiusSquare=(x1-x0)*(x1-x0)+(y1-y0)*(y1-y0)+(z1-z0)*(z1-z0); radius=Math.sqrt(radiusSquare);//开根号方法 return radius; } //计算体积的方法 public static double getVolume(double x0,double y0,double z0,double x1,double y1,double z1){ double volume=0; //调用math中的方法,也可以用r*r*r volume=4*Math.acos(-1)*Math.pow(getRadius(x0,y0,z0,x1,y1,z1), 3)/3; return volume; } }
import java.text.DecimalFormat; import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner scanner = new Scanner(System.in); int x1 = scanner.nextInt(); int y1 = scanner.nextInt(); int z1 = scanner.nextInt(); int x2 = scanner.nextInt(); int y2 = scanner.nextInt(); int z2 = scanner.nextInt(); double r = Math.sqrt(Math.pow(x1-x2,2)+Math.pow(y1-y2,2)+Math.pow(z1-z2,2)); double v = 4/3.0*Math.acos(-1)*Math.pow(r,3); DecimalFormat format = new DecimalFormat("0.000"); System.out.println(format.format(r)+" "+format.format(v)); } }
#include<iostream> (720)#include<cmath> #include<iomanip> using namespace std; int main(){ int x0,y0,z0; int x1,y1,z1; while(cin>>x0>>y0>>z0>>x1>>y1>>z1){ double r = sqrt((x1-x0)*(x1-x0)+(y1-y0)*(y1-y0)+(z1-z0)*(z1-z0)); cout<<setiosflags(ios::fixed)<<setprecision(3)<<r<<" " <<setiosflags(ios::fixed)<<setprecision(3)<<4*acos(-1)*r*r*r/3<<endl; } return 0; }
import math while True: try: numList = list(map(int,input().split())) radius = ((numList[3]-numList[0])**2+(numList[4]-numList[1])**2+(numList[5]-numList[2])**2)**0.5 volume = 4/3*math.acos(-1)*(radius**3) print('%.3f %.3f' % (round(radius,3),round(volume,3))) except Exception as message: break
#include<stdio.h> #include<math.h> int main() { double x0, y0, z0; double x1, y1, z1; scanf("%lf%lf%lf", &x0, &y0, &z0); scanf("%lf%lf%lf", &x1, &y1, &z1); double r = pow(pow(x1-x0, 2) + pow(y1-y0, 2) + pow(z1-z0, 2),1.0/2);//空间坐标算距离,平方和开方 double area = 4.0/3 * acos(-1) * pow(r, 3);//球的体积公式 printf("%.3lf %.3lf\n", r, area); return 0; }
#include <iostream> #include <cmath> using namespace std; int main(int argc, char * argv[]){ double x0, y0, z0, x, y, z;while (cin >> x0 >> y0 >> z0 >> x >> y >> z){double R = sqrt((x0-x)*(x0-x)+(y0-y)*(y0-y)+(z0-z)*(z0-z)); printf("%.3lf %.3lf\n", R, 4.0/3*3.14159265358979323846*R*R*R);}return 0;}
#include<iostream> #include<cstdio> #include<cmath> using namespace std; double myfabs(double x, double y) { return x-y > 0 ? x-y : y-x; } int main() { double x0, y0, z0; double x1, y1, z1; while(cin >> x0 >> y0 >> z0 >> x1 >> y1 >> z1) { double r = sqrt(myfabs(x0,x1)*myfabs(x0,x1)+myfabs(y0,y1)*myfabs(y0,y1)+myfabs(z0,z1)*myfabs(z0,z1)); double v = 4.0*r*r*r*acos(-1)/3.0; // arccos 对应函数 acos printf("%.3lf %.3lf\n", r, v); } return 0; }
#include <iostream> #include <iomanip> #include <cmath> using namespace std; int main(){ int a,b,c,d,e,f; double g; while(cin>>a){ cin>>b>>c>>d>>e>>f; g=(double)((d-a)*(d-a)+(e-b)*(e-b)+(f-c)*(f-c)); g=sqrt(g); cout<< fixed <<setprecision(3)<<g<<" "<<acos(-1)*g*g*g*4/3<<endl; } return 0; }
#include<iostream> (720)#include<math.h> using namespace std; int main(){ double x0,y0,z0,x1,y1,z1; double r,V; int temp; while(cin>>x0>>y0>>z0>>x1>>y1>>z1){ r=sqrt((x1-x0)*(x1-x0)+(y1-y0)*(y1-y0)+(z1-z0)*(z1-z0)); //temp=r*1000; //r=temp/1000; V=4*acos(-1)*r*r*r/3; printf("%.3lf %.3lf\n",r,V); } return 0; }
#include<iostream> #include<iomanip> #include<cmath> using namespace std; int main(){ double x0,y0,z0,x1,y1,z1; double r; double size; while(cin>>x0>>y0>>z0>>x1>>y1>>z1){ r=sqrt((x1-x0)*(x1-x0)+(y1-y0)*(y1-y0)+(z1-z0)*(z1-z0)); size=r*r*r*acos(-1)*4/3; cout<<fixed<<setprecision(3)<<r<<" "; cout<<fixed<<setprecision(3)<<size<<endl; } return 0; }
#include <iostream>
#include <cstdio>
#include <cmath>
using namespace std;
int main(){
double x0,y0,z0,x1,y1,z1;
cin >> x0 >> y0 >> z0 >> x1 >> y1 >> z1;
double dxy = sqrt( (x1-x0)*(x1-x0) + (y1-y0)*(y1-y0) );
double r = sqrt(dxy*dxy + (z1-z0)*(z1-z0));
double v = acos(-1)*pow(r,3)*4/3;
printf("%.3f %.3f", r, v);
return 0;
}
#include <cmath> #include <cstdio> #include <iostream> using namespace std; int main() { double x0, y0, z0, x1, y1, z1; while (cin >> x0 >> y0 >> z0 >> x1 >> y1 >> z1) { double rx = x1 - x0; //半径在x轴上的投影 double ry = y1 - y0; //半径在y轴上的投影 double rz = z1 - z0; //半径在z轴上的投影 double r = sqrt(rx * rx + ry * ry + rz * rz); //半径 double pi = acos(-1); //PI值 double v = 4.0 / 3 * pi * r * r * r; //体积 printf("%.3f %.3f\n", r, v); } return 0; }
#include <cstdio> #include <cmath> int main(){ int x0,y0,z0, x1,y1,z1; double R,V; while(scanf("%d %d %d %d %d %d",&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*acos(-1)*R*R*R; printf("%.3lf %.3lf\n",R,V); } return 0; }
#include <stdio.h> #include <math.h> int main() { int x0, y0, z0, x1, y1, z1; while (scanf("%d%d%d%d%d%d", &x0, &y0, &z0, &x1, &y1, &z1) != EOF) { double r = sqrt(pow(x0 - x1, 2) + pow(y0 - y1, 2) + pow(z0 - z1, 2)); printf("%.3lf ", r); printf("%.3lf\n", ((double)4 / 3) * acos(-1) * pow(r, 3)); } return 0; }
#include<stdio.h> #include<stdlib.h> #include<string.h> #include<math.h> int main() { int x0, y0, z0, x1, y1, z1; while (scanf("%d %d %d %d %d %d\n", &x0, &y0, &z0, &x1, &y1, &z1) != EOF) { double r = sqrt((x0 - x1) * (x0 - x1) + (y0 - y1) * (y0 - y1) + (z0 - z1) * (z0 - z1)); double v = 4.0000000 / 3.0000000 * acos(-1) * r * r * r; printf("%.3f %.3f\n", r, v); } }