[求助]
请问各位大虾,求任意两个数的最大公约数的程序怎么写啊?
#include "stdio.h" long caculate(long num1,long num2) { long a,b,t; if(num1>num2) { a=num1; b=num2; } else { a=num2; b=num1; } t=a%b; while (t!=0) { a=b; b=t; t=a%b; } return b; }
void main() { long number1,number2,result; printf("please input the number:\n"); scanf("%d%d",&number1,&number2); result=caculate(number1,number2); printf("the input is %d and %d ,the result is %d\n",number1,number2,result); }