}
doublepower(inta,intb)
{intmul=1,i;
for(i=0;i
mul=mul*a;
returnmul;
}
4.
#include
usingnamespacestd;
voidmain()
{
cout<<"学号:
"<cout<<"========================================="<intx,y,z,gy,gb;
intmax(intm,intn);
intmin(intm,intn);
cout<<"请输入2个正整数:
";
cin>>x>>y;
if(x{z=x;
x=y;
y=z;}
gy=max(x,y);
gb=min(x,y);
cout<<"最大公约数是:
"<cout<<"最小公倍数是:
"<}
intmax(intm,intn)
{
intt;
t=m%n;
while(t!
=0)
{
m=n;
n=t;
t=m%n;
}
returnn;
}
intmin(intm,intn)
{
intmax(int,int);
return(m*n)/max(m,n);
}
5.
#include
usingnamespacestd;
voidmain()
{
cout<<"学号:
"<cout<<"========================================="<intm,n,i,j,sum;
sum=0;
boolfact(inti);
cout<<"请输入2个正整数m,n:
";
cin>>m>>n;
for(i=m;i<=n;i++)
if(fact(i))
sum=sum+i;
cout<"<}
boolfact(intm)
{
intsum=0,i;
for(i=1;iif(m%i==0)
sum=sum+i;
if(sum==m)
returntrue;
else
returnfalse;
}