int gjs(int m,int n) { int p,t; if(m>n) {p=m; m=n; n=p; } while(n!=0) { t=m%n; m=n; n=t; } return nint gjs(int m,int n){int p,t;if(m>n){p=m;m=n;n=p;}while(n!=0){t=m%n;m=n;n=t;}return n;}#include #include int main(){int a;int b;scanf("%d%d",&a,&b);pri

来源:学生作业帮助网 编辑:作业帮 时间:2024/11/15 03:29:08

int gjs(int m,int n) { int p,t; if(m>n) {p=m; m=n; n=p; } while(n!=0) { t=m%n; m=n; n=t; } return nint gjs(int m,int n){int p,t;if(m>n){p=m;m=n;n=p;}while(n!=0){t=m%n;m=n;n=t;}return n;}#include #include int main(){int a;int b;scanf("%d%d",&a,&b);pri
int gjs(int m,int n) { int p,t; if(m>n) {p=m; m=n; n=p; } while(n!=0) { t=m%n; m=n; n=t; } return n
int gjs(int m,int n)
{
int p,t;
if(m>n)
{p=m;
m=n;
n=p;
}
while(n!=0)
{
t=m%n;
m=n;
n=t;
}
return n;
}
#include
#include
int main()
{
int a;
int b;
scanf("%d%d",&a,&b);
printf("%d\n",gjs(a,b));
return 0;
}
一直输出时0;为什么?
me知道了

int gjs(int m,int n) { int p,t; if(m>n) {p=m; m=n; n=p; } while(n!=0) { t=m%n; m=n; n=t; } return nint gjs(int m,int n){int p,t;if(m>n){p=m;m=n;n=p;}while(n!=0){t=m%n;m=n;n=t;}return n;}#include #include int main(){int a;int b;scanf("%d%d",&a,&b);pri
明显的错误:看你的WHILE循环,要是n不是0它也出不来啊!结果你返回了一个必为0的n结果当然为0了.
while(n%m!=0)
{
t=n%m;
n=m;
m=t;
}
return m;手机答的不能调试,应该对的.;-)