Posted on 2007-06-30 21:30
停留的风 阅读(459)
评论(0) 编辑 收藏 所属分类:
C语言学习历程
#include <stdio.h>
int gcd(int u,int v)
{
int temp;
while(v!=0)
{
temp=u%v;
u=v;
v=temp;
}
return u;
}
int main(void)
{
printf("Input in two int numbers!\n");
int a[2],number;
for(int i=0;i<2;i++)
{
scanf("%i",&number);
a[i]=number;
}
printf("The gcd of %i and %i is %i\n ",a[0],a[1],gcd(a[0],a[1]));
return 0;
}