| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 4572 人关注过本帖
标题:c 函数最大公约数 最小公倍数问题
只看楼主 加入收藏
星野
Rank: 2
来 自:河北
等 级:论坛游民
帖 子:73
专家分:26
注 册:2016-4-13
结帖率:82.35%
收藏
 问题点数:0 回复次数:1 
c 函数最大公约数 最小公倍数问题
#include<stdio.h>
int main()
{
    int gongyshu(int int);
    int gongbshu(int int int);
    int x,y;
    int m,n;
    scanf("%d %d",&x,&y);
    m=int gongyshu(int,int);
    n=int gongbshu(int,int,int);
    printf("%d\n",m);
    printf("%d\n",n);
    return 0;
}
int gongyshu(int a,int b)
{
    int a,b,c,t;
    if(a<b)
    {
        t=a;
        a=b;
        b=c;
    }
    p=a*b;
    while(b!=0)
    {
        c=a%b;
        a=b;
        b=c;
    }
    return a;
}
int gongbshu(int a,int b,int p)
{
    int z;
    z=p/a;
    return (z);
}

帮我看看  我的程序好混乱啊、、
搜索更多相关主题的帖子: 最小公倍数 include return 公约数 
2016-05-06 13:58
星野
Rank: 2
来 自:河北
等 级:论坛游民
帖 子:73
专家分:26
注 册:2016-4-13
收藏
得分:0 
#include<stdio.h>
int main()
{
    int yshu(int,int);
    int bshu(int,int,int);
    int a,b;
    int m,n;
    scanf("%d %d",&a,&b);
    m=yshu(a,b);
    n=bshu(a,b,m);
    printf("%d\n",m);
    printf("%d\n",n);
    return 0;
}
int yshu(int a,int b)
{
    int c,t;
    if(a<b)
    {
        t=a;
        a=b;
        b=c;
    }

    while(b!=0)
    {
        c=a%b;
        a=b;
        b=c;
    }
    return a;
}
int bshu(int a,int b,int m)
{


    return (a*b/m);
}

我刚刚改了一下   还是不对 为什么??
2016-05-06 14:14
快速回复:c 函数最大公约数 最小公倍数问题
数据加载中...
 
   



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

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