府河音乐花园二手房:一道PASCAL题目,要整个程序,题目是这样的:

来源:百度文库 编辑:杭州交通信息网 时间:2024/04/30 06:46:57
把1993拆成两个正整数的和, 再把这两个数相乘. 如果在
乘积中出现1,9,9,3各一次, 就把这种拆法记录下来. 一共有
多少种?

var i,j,ans:integer;
total:longint;
a:array[0..9]of integer;
begin
ans:=0;
for i:=1 to 996 do
begin
for j:=0 to 9 do
a[j]:=0;
j:=1993-i;
total:=i*j;
repeat
inc(a[total-(total div 10)*10]);
total:=total div10;
until total=0;
if (a[1]=1)and(a[3]=1)and(a[9]=2) then inc(ans);
end;
writeln('There are ',ans,' kinds of dividing!');
end.