#include"stdio.h"int fac(int a,int b){ int m;if(a%b==0)m=b;else m=fac(b,a%b);return m;}void main(){ int a,b,m; printf("please input two number:"); scanf("%d%d",&a,&b); if(a<b) {m=a;a=b;b=m;}printf("the max common factor is:%d\n",fac(a,b));}递归我也不太会,还好题不算难,算法用的是辗转求余法 |