输出两个数的最大公约数

#include <stdio.h>
int main()
{
int a,b;
printf("enter two numbers:");
scanf("%d,%d",&a,&b);
while(a!=b)
{
	if(a>b) a=a-b;
	else b=b-a;

}
printf("%d",a);
return 0;

}
#include <stdio.h>
int main()
{
int a,b;
printf("enter two numbers:");
scanf("%d,%d",&a,&b);
while(a*b!=0)
{
	if(a>b){ a=a%b};
	else if{  b=b%a};
     else
     {return x;
     }
}
return x==0?y:x;
printf("%d",a);
return 0;

}

猜你喜欢

转载自blog.csdn.net/shoushou_/article/details/89433067