辗转相除求最大公约数,这个程序是哪里不对吗?#includeint main(){int gcd(int x,int y);int a,b,d;printf("please input the number from the bigger to the smaller:");//从大到小输入两个数,便于后面辗转相除计算scanf("%d,%d

来源:学生作业帮助网 编辑:作业帮 时间:2024/07/19 19:49:41
辗转相除求最大公约数,这个程序是哪里不对吗?#includeint main(){int gcd(int x,int y);int a,b,d;printf(
xOo0O&S*E.4)_dH%)BVĠ$@eLԖ[he$=2G50_f/h~M_{w%g/G8HrLŪ ޴aMh8V Sdc$`&|ZogC-B^;6[p[աUh ;B!c|<#|qLxLm2xIWޖ{'o004DRTt__p ?q@-H kzn)a68'9;OˇZ=+p}`jn"A2[0l սF#,>QbmeCsC*FN1뢣n,1)^®{m^S_^N9Ohi "I7r.I[PJ#NVN%<MN8ޡȁ&{_

辗转相除求最大公约数,这个程序是哪里不对吗?#includeint main(){int gcd(int x,int y);int a,b,d;printf("please input the number from the bigger to the smaller:");//从大到小输入两个数,便于后面辗转相除计算scanf("%d,%d
辗转相除求最大公约数,这个程序是哪里不对吗?
#include
int main()
{int gcd(int x,int y);
int a,b,d;
printf("please input the number from the bigger to the smaller:");//从大到小输入两个数,便于后面辗转相除计算
scanf("%d,%d,&a,&b");
d=gcd(a,b);//调用函数
printf("the greatest common divisor is %d\n",d);
return 0;
}
int gcd(int x,int y)
{int c;
while(y!=0)
{c=x%y;
x=y;
y=c;}
return (x);//输出除数
}

辗转相除求最大公约数,这个程序是哪里不对吗?#includeint main(){int gcd(int x,int y);int a,b,d;printf("please input the number from the bigger to the smaller:");//从大到小输入两个数,便于后面辗转相除计算scanf("%d,%d
修改如下:
#include
int main()
{int gcd(int x,int y);
int a,b,d;
printf("please input the number from the bigger to the smaller:");//从大到小输入两个数,便于后面辗转相除计算
scanf("%d %d",&a,&b);
d=gcd(a,b);//调用函数
printf("the greatest common divisor is %d\n",d);
return 0;
}
int gcd(int x,int y)
\x05{int c;
\x05while(y!=0)\x05\x05
{c=x%y;
x=y;
y=c;}
return (x);//输出除数
}
上面的scanf写错了,你对比一下.