作业帮 > 综合 > 作业

Sum to N pascal

来源:学生作业帮 编辑:搜狗做题网作业帮 分类:综合作业 时间:2024/07/07 09:30:52
Sum to N pascal
对任意给定的N (4
Sum to N pascal
const a:array[1..2]of longint=(-1,1); var s,s1,n:longint; h:array[2..24]of longint; procedure js; var i:longint; begin for i:=2 to n-1 do s1:=s1+h[i]*i; if s1=n+1 then s:=s+1; s1:=0; end; procedure try(dep:longint); var i:longint; begin if dep>n-1 then js else for i:=1 to 2 do begin h[dep]:=a[i]; try(dep+1) end; end; begin assign(input,'sum.in'); reset(input); assign(output,'sum.out'); rewrite(output); readln(n); s:=0; s1:=0; try(2); writeln(s); close(input); close(output); end. 8好意思,可能晚了
记得采纳啊