#include<stdio.h>
#include<stdlib.h>
int main(void)
{
int num1,num2,temp,max,min,gcd;
scanf("%d %d",&num1,&num2);
if(num2>num1)
{
max=num2;
min=num1;
while((temp=max%min)!=0)
{
min=max;
max=temp;
}
gcd=max;
printf("%d ",gcd );
}
else
{
max=num1;
min=num2;
while((temp=max%min)!=0)
{
max=min;
min=temp;
}
gcd=min;
printf("%d ",gcd );
}
system("PAUSE");
return 0;
}
-------------------------------------------------------------------------------
改成
#include<stdio.h>
#include<stdlib.h>
int main(void)
{
int num1,num2,temp,max,min,gcd;
scanf("%d %d",&num1,&num2);
if(num2>num1)
{
max=num2;
min=num1;
while((temp=max%min)!=0)
{
min=max;
max=temp;
}
gcd=max;
printf("%d ",gcd );
}
else
{
max=num1;
min=num2;
while((temp=max%min)!=0)
{
max=min;
min=temp;
}
gcd=min;
printf("%d ",gcd );
}
return 0;
}