[討論] while用法

看板MATLAB作者 (chris)時間7年前 (2017/04/12 01:05), 編輯推噓1(105)
留言6則, 1人參與, 最新討論串1/1
想請益如何用while loop 計算1+2+3+....+999 謝謝 -- ※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 140.122.34.242 ※ 文章網址: https://www.ptt.cc/bbs/MATLAB/M.1491930300.A.FFA.html

04/12 11:54, , 1F
num = 1;
04/12 11:54, 1F

04/12 11:54, , 2F
result = 0;
04/12 11:54, 2F

04/12 11:54, , 3F
while num < 1000
04/12 11:54, 3F

04/12 11:54, , 4F
result = result + num
04/12 11:54, 4F

04/12 11:54, , 5F
num += 1;
04/12 11:54, 5F

04/12 11:55, , 6F
end
04/12 11:55, 6F
文章代碼(AID): #1OxGoy_w (MATLAB)
文章代碼(AID): #1OxGoy_w (MATLAB)