大大多的题目(PASCAL语言)
来源:学生作业帮 编辑:搜搜考试网作业帮 分类:数学作业 时间:2024/08/15 14:49:44
大大多的题目(PASCAL语言)
1.给出一个自然数N(1
1.给出一个自然数N(1
![大大多的题目(PASCAL语言)](/uploads/image/z/2274924-12-4.jpg?t=%E5%A4%A7%E5%A4%A7%E5%A4%9A%E7%9A%84%E9%A2%98%E7%9B%AE%28PASCAL%E8%AF%AD%E8%A8%80%29)
1.
var n:longint;
a:array[1..1000]of longint;
procedure dg(x:longint);
var i,k,j,y,z:longint;
begin
k:=0;
for i:=x to x+(n-1) do begin
inc(k);
a[k]:=i;
end;
j:=(n+1)div 2;
for i:=1 to j do begin
y:=a[i]*a[i]+y;
end;
j:=(n-1)div 2;
for i:=j downto (n+1)div 2+1 do begin
z:=a[i]*a[i]+z;
end;
if z=y then for i:=1 to n do write(a[i],' ')else dg(x+1);
end;
begin
readln(n);
dg(1);
end.
如果楼主看得明思路就自己改一下吧
我还要做下面的题拿100分
第一题仍然是错的啊
2.
var a,b,c,d,e,f,g:longint;
begin
readln(a)
write(a,'=');
for b:=3 to a do
begin
e:=1;
if a mod b=0 then
begin
for g:=2 to round(sqrt(a)) do
if a mod g=0 then e:=0;
if (e=1)or(a=1) then begin write(b);exit;end;
e:=1;
for c:=2 to round(sqrt(b)) do
if b mod c=0 then e:=0;
if e=1 then begin write(b,'*');a:=a div b;end;
end;
end;
end.
var n:longint;
a:array[1..1000]of longint;
procedure dg(x:longint);
var i,k,j,y,z:longint;
begin
k:=0;
for i:=x to x+(n-1) do begin
inc(k);
a[k]:=i;
end;
j:=(n+1)div 2;
for i:=1 to j do begin
y:=a[i]*a[i]+y;
end;
j:=(n-1)div 2;
for i:=j downto (n+1)div 2+1 do begin
z:=a[i]*a[i]+z;
end;
if z=y then for i:=1 to n do write(a[i],' ')else dg(x+1);
end;
begin
readln(n);
dg(1);
end.
如果楼主看得明思路就自己改一下吧
我还要做下面的题拿100分
第一题仍然是错的啊
2.
var a,b,c,d,e,f,g:longint;
begin
readln(a)
write(a,'=');
for b:=3 to a do
begin
e:=1;
if a mod b=0 then
begin
for g:=2 to round(sqrt(a)) do
if a mod g=0 then e:=0;
if (e=1)or(a=1) then begin write(b);exit;end;
e:=1;
for c:=2 to round(sqrt(b)) do
if b mod c=0 then e:=0;
if e=1 then begin write(b,'*');a:=a div b;end;
end;
end;
end.