pascal问题

2025-02-25 08:20:06
推荐回答(5个)
回答1:

....刚学么
别太心急
要从最基本的学起啊
第一行是程序名
可有可无
第二行
定义a
t两个变量
都是整数~
第四行
a:=1是赋值语句
这个非常基础的啊``就是让A=1
(
如果直接写A=1的话是判断"A是否等于1"
而不是赋值
)
t在这个程序里是代表REPEAT~UNTIL那部分的语句执行的次数
每执行一次t就+1
a就是代表t个1992相乘的最后两位啊
因为只要考虑最后两位
所以只要*92就够了(而不需要*1992
如果你改成*1992也行~)
然后a*92的结果也只需要取最后两位就好了
所以mod
100(除以100取余数
就是取最后两位的意思)
最后输出A就好了
还有不懂的再补充吧
不懂你的数学水平到啥程度
能否理解余数之类的东西..(比小学学的更深)
还有如果你刚学的话
在网上搜一些初级教程
从基本学期
不要心急啊~尤其是你不懂得赋值语句```明显是没去打基础的
切忌心急啊~

回答2:

1.
program
sd;
var
a:array[1..5]of
integer;
n,i:longint;
function
gongb(num1:integer;num2:integer):integer;
var
j:longint;
begin
for
j:=num1
to
num1*num2
do
if
(j
mod
num1=0)
and
(j
mod
num2=0)
then
begin
gongb:=j;
exit;
end;
end;
begin
n:=1;
for
i:=1
to
5
do
begin
read(a[i]);
n:=gongb(a[i],n);
end;
writeln(n);
end.
2.
program
sd;
var
i,p,q:integer;
function
pou(a:integer):boolean;
var
j,n:integer;
begin
n:=0;
for
j:=1
to
a
do
if
a
mod
j=0
then
n:=n+1;
if
n=2
then
pou:=true
else
pou:=false;
end;
begin
for
i:=6
to
100
do
if
i
mod
2=0
then
begin
p:=1;
repeat
p:=p+1;
q:=i-p;
until
(pou(p))
and
(pou(q));
writeln(i,'=',p,'+',q);
end;
end.
3.(1)
program
sd;
var
i,j:integer;
function
pan(a:integer):boolean;
var
m,n:integer;
begin
m:=0;
for
n:=1
to
a
do
if
a
mod
n=0
then
m:=m+1;
if
m=2
then
pan:=true
else
pan:=false;
end;
begin
for
i:=10
to
99
do
begin
j:=(i
mod
10)*10+i
div
10;
if
(pan(i))and(pan(j))
then
writeln(i);
end;
end.
3.(2)
program
sd;
var
i:array[1..10]of
longint;
j:integer;
he:boolean;
function
phe(a:longint):boolean;
var
m,n:longint;
begin
n:=0;
for
m:=1
to
a
do
if
a
mod
m=0
then
n:=n+1;
if
n>2
then
phe:=true
else
phe:=false;
end;
begin
for
j:=1
to
10
do
i[j]:=j-1;
repeat
for
j:=1
to
10
do
i[j]:=i[j]+1;
he:=true;
for
j:=1
to
10
do
he:=he
and
phe(i[j]);
until
he;
for
j:=1
to
10
do
writeln(i[j]);
end.
4.
program
sd;
var
n,j:integer;
procedure
wrs(a:integer);
var
k:integer;
begin
write(a,'=');
for
k:=1
to
a
do
if
k=1
then
write(a)
else
write('+',a);
writeln;
end;
begin
readln(n);
for
j:=1
to
n
do
wrs(j);
end.
第5不会
6.
program
asd;
var
i:integer;
function
ch(a:integer):boolean;
var
s,m:string;
j,n:integer;
begin
n:=0;
s:='';
str(a,m);
for
j:=3
downto
1
do
s:=s+m[j];
if
s=m
then
ch:=true
else
ch:=false;
for
j:=1
to
a
do
if
a
mod
j=0
then
n:=n+1;
ch:=ch
and
(n=2);
end;
begin
for
i:=100
to
999
do
if
ch(i)
then
writeln(i);
end.
7.
program
fb;
var
a:array[1..30]of
longint;
i:integer;
begin
a[1]:=0;
a[2]:=1;
for
i:=3
to
30
do
a[i]:=a[i-1]+a[i-2];
for
i:=1
to
30
do
begin
write(a[i],'
');
if
i
mod
5=0
then
writeln;
end;
end.

回答3:

第二题
type
rec=record
jia,jian,cheng,chu:integer;
end;
var a:array[1..9] of rec;
i,j:integer;
begin
for i:=1 to 9 do begin
j:=i*4;
if (j-4>=10) and (j*4>=10) and(j*4<=99) then with a[i] do begin
jia:=j-4;jian:=j+4;cheng:=i;chu:=j*4;
end;
end;
for i:=1 to 9 do with a[i] do if jia<>0 then writeln(jia,' ',jian,' ',cheng,' ',chu);
end.

第三题
type
rec=record
n:integer;
r:real;
end;
var a:array[1..9] of rec;
i,j,t1:integer;
t2:real;
begin
for i:=1 to 3 do
begin
for j:=1 to 3 do
read(a[(i-1)*3+j].n,a[(i-1)*3+j].r);
readln;
end;
for i:=1 to 8 do
for j:=i to 9 do
if a[i].r t1:=a[i].n;a[i].n:=a[j].n;a[j].n:=t1;
end;

writeln(' M N S');
for i:=1 to 9 do writeln(i,' ',a[i].n,' ',a[i].r:0:1);
end.

第三题做别字N多 看不懂```

回答4:

for
m:=2
to
n
do

begin

x:=x+w[f,1];

y:=y+w[f,2];

end;
这里因为在循环的步骤中并没有提及循环变量m,因此m应该表示循环步骤进行的次数(即进行(n-2+1)次),w在这里应该是一个二维数组,x和y都是累加器,而f仅仅充当下标。

回答5:

因为本人时间有限,所以我用10分钟帮你解决了D1个问题。
program
stat;
var
ch:char;
i:longint;
fin,fout:text;
begin
i:=0;
assign(fin,'stat.in');
reset(fin);
assign(fout,'stat.out');
rewrite(fout);
while
not(eof(fin))
do
begin
read(fin,ch);
if
ch='1'
then
i:=i+1;
end;
writeln(fout,i);
close(fin);
close(fout);
end.
我的邮箱:jack_lvzheng@163.com