C语言课后习题

/*最大公约数求解*/
#include "stdafx.h"
#include <stdio.h>
int main()
{
 int max(int,int);
 int a,b;
 printf("Please input your numbers\n");
 scanf("%d,%d\n",&a,&b);
 printf("最大公约数为:%d\n",max(a,b));
 return 0;
}
int max(int,int)
{
 int a,b,r;
 int t;
 if(b>a)
 {
  b=t;
  t=b;
  b=a;
 }
 while(r=a/b!=0)
 { 
  a=b;
  b=r;
 return b;
 }
}

猜你喜欢

转载自www.cnblogs.com/pquan/p/10884199.html