?? 階乘.txt
字號:
\\程序完成的是 n! 的連加和,從 1 到 所輸入的值
\\輸入的值應該小于13,因為超過這個界限會導致數(shù)的越界
var subresult , result , upperbound , i , flag;
begin
read(flag);
while flag=0 do \\是否進行運算
begin
read(upperbound); \\讀入數(shù)據(jù)
write(upperbound); \\反寫出讀入的數(shù)據(jù)
i := 0;
result:=0;
if upperbound>=0 then \\判斷讀入的數(shù)據(jù)是否正確
if upperbound<=12 then \\兩個if 實現(xiàn) && 的功能
while i<=upperbound do
begin
if i = 0 then
subresult := 1;
if i # 0 then
subresult := subresult * i;
result := result + subresult ;
i := i+1
end;
write(result);
read(flag) \\是否繼續(xù)
end;
end.
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -