Loading...

    AD: 猛买 | 快递查询 | Jobsdigg | 很棒的男装店

学了C,写一段看看(求最小公倍数)

可任意转载,但必须在醒目位置以超链接形式标明文章原始出处和作者信息
原文地址:http://www.blogkid.net/archives/61.html

Code:

#include <stdio.h>

#include <math.h>

main ()

{

int a,b,result,yue;

printf ("please input two numbers \n")

scanf ("%d,%d",&a,&b);

yue=yue(a,b);

result=a*b/yue;

printf ("the result is %d \n",result);

}

yue (int x,int y) /*求最大公约数的子函数*/

{

int a

while (x%a!=0||y%a!=0) /*辗转相减法*/

{

if x>y

{

a=x-y;

x=a;

}

else

{

a=y-x;

y=a;

}

}

return (a);

}

********************************************************

没有电脑,连调试的机会也没有

0 Responses to “学了C,写一段看看(求最小公倍数)”


  1. No Comments

Leave a Reply