fct.pas
来自「This ar the basic programs that i did in」· PAS 代码 · 共 37 行
PAS
37 行
program functie_function;
{ 2x+1, pt. x>=-1
Sa se calculeze f:R-R; f(x)=
3x+2, pt. x<-1
Sa sa calculeze: f(1)+f(2)+...+f(n)}
var i,n:integer;
s:real;
a:array[1..100] of real;
function fct(x:real):real;
begin
if x>=-1 then fct:=2*x+1
else fct:=3*x+2;
end;
begin
readln(n);
s:=0;
for i:=1 to n do
begin
write('a[',i,']= ');
readln(a[i]);
end;
i:=1;
repeat
begin
writeln(fct(a[i]):4:1);
s:=s+fct(a[i]);
i:=i+1;
end;
until i=n+1;
writeln('f(1)+...f(',n,')= ',s:4:1);
end.
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?