1樓:烈焰極光
(1)var
sum,i:longint;
begin
i:=0;sum:=0;
while sum<32767 do
begin
i:=i+1;sum:=sum+1;
end;
writeln(i);
end.
(2)var
t,i,sum:longint;
begin
for i:=1 to 10000 do
begin
sum:=sum+i;
if sum>=32767 then
begin
t:=i;break;
end;
end;
writeln(t);
end.
(3){推薦,二分法+數學方法,效率o(logn);
vart:longint;
begin
t:=10000 div 2;i:=2500;
while (t*(t+1) div 2<32767) or (t*(t-1) div 2>=32767) do
begin
if (t*(t+1) div 2<32767 then t:=t+i else t:=t-i;
i:=i div 2+1;
end;
writeln(t);
end.
2樓:0史記
vari,s:longint;
begin
i:=0;
s:=0;
repeat
i:=i+1;
s:=s+i;
until s>=32767;
writeln(i);
readln;
end.
3樓:
var a,c:longint;
begin
c:=0;
a:=1;
while c<32767 then
begin
c:=c+a;
a:=a+1;
end;
writeln(a);
可以在此加一句readln;
end.
free pascal問題跪求
vara,b,c,t longint begin readln a,b,c if at a a b b t end if a0 then writeln sqrt x 0 5 else if x 0 then writeln x 0 else writeln x 0 readln end.vara,...
關於Free Pascal程式設計問題
迴圈問題。樓上講得很詳細,對樓上的進行補充一下迴圈語句的基本格式,這對初學者的用處也是不可忽視,得從基本的開始,先掌握理論,進行實戰,事半功倍。for 迴圈變數 初始值 to 終值 do迴圈體 接著就是了解方法,樓上已經把解題的方法講的很詳細了,綜合的應用就要看樓主自己的啦,多練習兩次,相信不難掌握...
用free pascal幫我完成以下練習!!急
no.1 vara,b,c integer begin a 1 b 12 c 123 writeln a writeln b writeln c writeln writeln a 3 writeln b 3 writeln c 3 end.no.2 varn,i integer begin rea...