标题:帮忙查看程序在哪出错,
取消只看楼主
guozhencai
Rank: 1
等 级:新手上路
帖 子:50
专家分:0
注 册:2005-3-9
 问题点数:0 回复次数:2 
帮忙查看程序在哪出错,
题目:输入两个正整数m和n,求其最大公约数和最小公倍数。
/* 标准文档模板 */

#include "Stdio.h"
#include "Conio.h"
int sb(int x,int y)
{int t;
while(y!=0)
{
t=x%y;
x=y;
y=t;
}
return y;
}
int sb1(int x,int y)
{int s;
s=x/y;
return s;
}
main()
{
int a,b,k,m,j;
printf("input two number a>b:");
scanf("%da,%d",&a,&b);
m=a*b;
k=sb(a,b);
j=sb1(m,k);
printf("k=%dj=%d",k,j);
getch();
}
帮忙查看程序在哪出错,
偶知道解这道题的方法很多,
这里就不用费心另写程序了,
只要帮我查看一下程序在哪出错,解释一下原因。谢谢!!!!
搜索更多相关主题的帖子: int include 
2005-04-17 09:18
guozhencai
Rank: 1
等 级:新手上路
帖 子:50
专家分:0
注 册:2005-3-9
得分:0 
while(y!=0)
{
t=x%y;
x=y;
y=t;
}
输入:50,30
20=50%30
10=30%20
0=20%10
return 10
会错吗?????

[此贴子已经被作者于2005-4-17 10:05:59编辑过]


2005-04-17 10:05
guozhencai
Rank: 1
等 级:新手上路
帖 子:50
专家分:0
注 册:2005-3-9
得分:0 
刚才我再次检查时也发现了这个问题。 但改来改去都不行。 最后才发现这一句多了一个 a。 scanf("%da,%d",&a,&b); 谢谢
2005-04-17 11:00



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




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

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