|
发表于 2004-12-26 00:49:37
|
显示全部楼层
/*
Name: 最大公约数
Author: zzz___hh__l 笔名:幽龙
Description:
Date: 25-12-04 15:02
Copyright:
*/
#include<iostream>
#include<cstdlib>
int zigongyuo(int b,int c)
{int r=c;
c=b;
while(r!=0)
{b=c;c=r;r=b%c;}
return c;
}
int gongyuo(int*a,int n)
{int t=a[0],i;
for(i=0;i<=n-1;i++)
t=zigongyuo(t,a);
return t;
}
main()
{ int*p,n,i;
cout<<"Enter the total of the number you'll enter"<<endl;
cin>>n;
cout<<"_______________________________________________________________"<<endl;
p=new int [n];
for(i=0;i<=n-1;i++)
{cout<<"Enter the "<<i<<"th number which is not zero"<<endl;
cin>>*(p+i);}
n=gongyuo(p,n);
cout<<"The number you want to know is———————— "<<n<<endl;
cout<<"_______________________________________________________________"<<endl;
system("AUSE");
return 0;
}
|
|