[問題] 關於while迴圈的問題
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