遞迴~公因數_輾轉相除
#include<stdio.h>
#include<stdlib.h>
int gcd(int a,int b)
{
if(a%b==0)
return b;
else
return gcd(b,a%b);
}
int main(void)
{
int a,b;
printf("Given two number:\n");
scanf("%d",&a);
scanf("%d",&b);
printf("GWe get the result:\n");
printf("gcd(%d,%d)=%d\n",a,b,gcd(a,b));
system("pause");
return 0;
}
Today's Visitors: 0 Total Visitors: 11
歷史上的今天:

Sealed (Aug 24)
Only friends can post a comment, Login first