
程序代码:
function distance = dist2 (x1, y1, x2, y2)
distance = sqrt((x2-x1).^2 + (y2-y1).^2);
disp('Calculate the distance between two points:');
ax = input ('Enter x value of point a:');
ay = input ('Enter y value of point a:');
bx = input ('Enter x value of point b:');
by = input ('Enter y value of point b:');
result = dist2 (ax, ay, bx, by);
fprintf('The distance between points a and b is %f \n', result);
嘿嘿,我是一个初学者。