var i,j,n:extended;
begin
readln(n);
if (n<=1) then begin
writeln(n*1.5:0:10);
end;
if n>1 then begin
i:=n-1;
writeln(i*0.8+1.5:0:10);
end;
end.
2楼的太麻烦
我的这更很简洁
而且答案精确到分
你只要输入公斤数
就会输出要多少钱
Var r,s:real;
Begin
Read(r);
If r<=1 then
Begin
Write(r*1.5);
Halt;
End
Else s:=1.5+(r-1)*0.8;
Write(s:0:2);
End.
简单问题,判断一次,用Halt退出程序,这个程序的时间复杂度和空间复杂度比LS的几位都小...
readln(n);
for i:=1 to n do read(a[i]);
sum:=0;
for i:=1 to n do
if (a[i]<=1) then sum:=sum+1.5 else sum:=sum+1.5+(a-1)*0.8;
writeln(sum);
要整个程序吗?我给你,给点分哦
program P1;
var
a:array[1..1000]of real;
n,i:longint;
s:real;
begin
readln(n);
for i:=1 to n do
read(a[i]);
s:=0;
for i:=1 to n do
if (a[i]<=1)
then s:=s+1.5
else s:=s+1.5+(a[i]-1)*0.8;
writeln(s:0:0);
end.绝对是对的哦,三楼的,我这就不精确到分吗,有的实型哦
program aa;
var
weigh:real;
begin
writeln('Please input the weigh(kg) of the luggage:');"输入重量"
read(weigh);"读入重量"
writeln;
if weigh<=1 then write('The price should be:',weigh*1.5:3)“判断收费标准”
else write('The price should be:',1.5+(weigh-1)*0.8:3);
end.