C语言:关于用辗转相除法递归求最大公约数,下面的程序有错误,请帮我改一下,谢谢!

[复制链接]
查看11 | 回复2 | 2010-12-19 22:28:13 | 显示全部楼层 |阅读模式
int gcd(int m,int n)
{

int r,t;

if(mint gcd(int m,int n){
int r,t;
//若mint gcd(int m,int n){
int r,t;
if(m<n)
{
t=m;
m=n;
n=t;
}
r=n;
n=m%n;
m=r;
if(n==0)
return
回复

使用道具 举报

千问 | 2010-12-19 22:28:13 | 显示全部楼层
这是两个算法的代码,主函数main()自己写,很简单 。int gcd(int x,int y) //辗转相除法求最大公约数{int z;do{z=x%y;x=y;y=z;}while(z!=0); return x;}int gcd(int n,int m) {
//这是递归if (n%m==0
回复

使用道具 举报

千问 | 2010-12-19 22:28:13 | 显示全部楼层
38,这都不知道,我也不知道
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

主题

0

回帖

4882万

积分

论坛元老

Rank: 8Rank: 8

积分
48824836
热门排行