一道pascal题目

[复制链接]
查看11 | 回复3 | 2012-2-28 12:53:28 | 显示全部楼层 |阅读模式
给你核心代码吧,这是判断两个数是否是亲密数对的函数:function main(a,b : longint) : boolean;vari,s1,s2 : longint;beginif (a = b) then
exit(false);s1 := 0;s2 := 0;for i := 1 to a-1 do
if (a mod i) = 0 then
inc(s1,i);for i := 1 to b-1 do
if (b mod i) = 0 then
inc(s2,i);if (s1 = b)and(s2 = a) then
exit(tru...
回复

使用道具 举报

千问 | 2012-2-28 12:53:28 | 显示全部楼层
vari,n,m,t,tt:longint;beginread(n,m);tt:=0;t:=0;for i:=1 to n-1 doif n mod i=0 then t:=t+i;for i:=1 to m-1 doif m mod i=0 then tt:=tt+i;if (t=m)and(tt=n) th...
回复

使用道具 举报

千问 | 2012-2-28 12:53:28 | 显示全部楼层
var a,b,tota,totb,i:longint;beginreadln(a,b);tota:=0;totb:=0;for i:=1 to trunc(sqrt(a)) dobeginif a mod i=0 then inc(tota,i);if a mod (a div i)=0 then inc(tota,a div i);if ...
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

主题

0

回帖

4882万

积分

论坛元老

Rank: 8Rank: 8

积分
48824836
热门排行