March 16, 2010

遞迴~公因數_輾轉相除

#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;
 }

0推薦此文章
Today's Visitors: 0 Total Visitors: 11
Personal Category: 科學 Topic: technology / tech info / programming
歷史上的今天:

誰來收藏
Loading ...
unlog_NVPO 0