1 条题解
-
0
C :
#include<stdio.h> #include<math.h> int main () { double a,b,c,d; while(scanf("%lf%lf%lf%lf",&a,&b,&c,&d)!=EOF) { printf("%.2lf\n",sqrt((a-c)*(a-c)+(b-d)*(b-d))); } return 0; }
C++ :
#include<iostream> #include <string> using namespace std; #include<cmath> #include<iomanip> int main(){ double x1, x2, y1, y2; double l; //int n = 10; while (cin >> x1 >> y1 >> x2 >> y2){ l = sqrt(pow((x1 - x2),2) + pow((y1 - y2),2)); cout << fixed << setprecision(2) << l << endl; //n--; } return 0; }
Java :
import java.util.Scanner; public class Main { public static void main(String[] argsStrings) { int x1,y1,x2,y2; double distance; Scanner inputScanner=new Scanner(System.in); while(inputScanner.hasNextInt()) { x1=inputScanner.nextInt(); y1=inputScanner.nextInt(); x2=inputScanner.nextInt(); y2=inputScanner.nextInt(); distance=Math.sqrt(Math.pow(x1-x2, 2)+Math.pow(y1-y2, 2)); System.out.printf("%.2f\n", distance); } } }
- 1
信息
- ID
- 1085
- 时间
- 1000ms
- 内存
- 128MiB
- 难度
- (无)
- 标签
- 递交数
- 0
- 已通过
- 0
- 上传者