Open krujeen opened 3 years ago
จงเขียนโปรแกรมรับเลขจำนวนเต็ม 4 จำนวน
โดย สองจำนวนแรกแทนพิกัดของจุดที่ 1 (x1,y1) สองจำนวนหลังแทนพิกัดของจุดที่ 2 (x2,y2)
จงคำนวณระยะห่างระหว่างจุดที่ 1 และ จุดที่ 2 ข้อมูลออกเป็นระยะห่างระหว่างจุดทั้งสอง และแสดงผลเป็นทศนิยมสองตำแหน่ง
ตัวอย่างการทำงาน 1 input
0 0 3 4
output
5.00
ตัวอย่างการทำงาน 2 input
3 2 5 8
6.32
import math x1 = float(input()) y1 = float(input()) x2 = float(input()) y2 = float(input()) d = math.sqrt(pow((x1-x2),2)+pow((y1-y2),2)) print ('%.2f'%(d))
จงเขียนโปรแกรมรับเลขจำนวนเต็ม 4 จำนวน
โดย สองจำนวนแรกแทนพิกัดของจุดที่ 1 (x1,y1) สองจำนวนหลังแทนพิกัดของจุดที่ 2 (x2,y2)
จงคำนวณระยะห่างระหว่างจุดที่ 1 และ จุดที่ 2 ข้อมูลออกเป็นระยะห่างระหว่างจุดทั้งสอง และแสดงผลเป็นทศนิยมสองตำแหน่ง
ตัวอย่างการทำงาน 1 input
output
ตัวอย่างการทำงาน 2 input
output