输入三个数,计算并输出它们的平均值以及三个数的乘积,写出程序

要求只能有3个变量

第1个回答  2013-04-01
我用VBPrivate Sub command1_click()
a = InputBox("请输入A的值")
a = Val(a)
b = InputBox("请输入B的值")
b = Val(b)
c = InputBox("请输入C的值")
c = Val(c)
Print "平均值" & (a + b + c) / 3, "乘积" & a * b * c
End Sub
第2个回答  2013-04-01
用循环的: program avemul(input,output);
var
ave,sum,mul,a:real;
i:integer;
begin
writeln('please input three numbers');
sum:=0;
mul:=1;
for i:=1 to 3
begin
read(a);
sum:=sum+a;
mul:=mul*a;
end;
ave:=sum/3;
writeln('ave=',ave:0:2);
writeln('mul=',mul:0:2);
end. 普通点的:program avemul(input,output);
var
a,b,c,ave,mul:real;
begin
writeln('please input three numbers');
read(a,b,c);
ave:=0;
mul:=1;
ave:=(a+b+c)/3;
mul:=a*b*c;
writeln('ave=',ave:0:2,' mul=',mul:0:2)
end.
相似回答