标题:用函数求最大公约数问题。为什么最后要用一句 a=fun1(a,b),而不是直接 retu ...
取消只看楼主
叶舞秋风
Rank: 1
等 级:新手上路
帖 子:10
专家分:0
注 册:2014-5-29
结帖率:66.67%
已结贴  问题点数:20 回复次数:0 
用函数求最大公约数问题。为什么最后要用一句 a=fun1(a,b),而不是直接 return a 呢?
#include<stdio.h>
void main()
{
    int a,b,c;
   int fun1(int,int);
    printf("请输入2个数:");
    scanf("%d,%d",&a,&b);
    c=fun1(a,b);
    printf("%d和%d的最大公约数是%d",a,b,c);
}
fun1(int a,int b)
{
    int t;
    if(b>a)
    {
        t=a;a=b;b=t;
    }
  t=a%b;
  a=b;
  b=t;
  if(b==0)
      return a;
  a=fun1(a,b);
}
搜索更多相关主题的帖子: return 公约数 
2014-07-21 10:50



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-434246-1-1.html




关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 2.057324 second(s), 8 queries.
Copyright©2004-2025, BCCN.NET, All Rights Reserved