注意:此页面搜索的是所有试题
题目内容
(国家开放大学Delphi程序设计)
本程序设计界面如下图所示:
procedure TForm1.Button1Click(Sender: TObject); //“计算”按钮
var
i , n, sum : integer ;
begin
sum := 0 ;
i := 1 ;
n := StrToInt(edit1.Text); //读入正整数n
while i <=n do //循环语句
begin
if odd( i ) then sum :=sum+i;
i := i +1 ;
end;
edit2.Text :=IntToStr( sum ); //将结果在编辑框中显示
end;
用户在edit1中输入一个正整数7,则在edit2中显示计算结果为:
A、7
B、14
C、16
D、21
procedure TForm1.Button1Click(Sender: TObject); //“计算”按钮
var
i , n, sum : integer ;
begin
sum := 0 ;
i := 1 ;
n := StrToInt(edit1.Text); //读入正整数n
while i <=n do //循环语句
begin
if odd( i ) then sum :=sum+i;
i := i +1 ;
end;
edit2.Text :=IntToStr( sum ); //将结果在编辑框中显示
end;
用户在edit1中输入一个正整数7,则在edit2中显示计算结果为:
A、7
B、14
C、16
D、21
参考答案

