作者thomas0908 (thomas宗)
看板MATLAB
标题[问题] 关於while回圈的问题
时间Sat Apr 6 19:56:02 2013
n_points = input('Enter the number of input [x y] points: ');
while n_points <= 0 && n_points > 0
n_points = input('Enter the number of input [x y] points: ');
isempty (n_points);
end
% Read the input data
for ii = 1:n_points
temp = input('Enter [x y] pair: ');
x(ii) = temp(1);
y(ii) = temp(2);
end
题目说修改程式使用一个while回圈,以便能读取任意数目的资料值,要求
当输入者为输入任何值时,而直接点及Enter键时,便停止读取任何资料
对於while回圈内的判断式以及条件式的打法要怎麽打会比较好?
(使用函式isempty来测试是否读取到一个空阵列)
--
※ 发信站: 批踢踢实业坊(ptt.cc)
◆ From: 140.135.33.155