使用c语言编程错误
我有这个程序,我试图输出n的值,但是我没有得到任何显示。程序符合但没有输出使用c语言编程错误,c,output,C,Output,我有这个程序,我试图输出n的值,但是我没有得到任何显示。程序符合但没有输出 #include <stdio.h> int rec(int x, int y) { static int count = 0; if(x==0) return count; count++; if(x > y) rec(x - y, y); else
#include <stdio.h>
int rec(int x, int y)
{
static int count = 0;
if(x==0)
return count;
count++;
if(x > y)
rec(x - y, y);
else
rec(x,y-x);
return count;
}
main(){
int i=0, j=2, n;
n = rec(i,j);
printf("%d", n);
}
#包括
内部记录(内部x,内部y)
{
静态整数计数=0;
如果(x==0)
返回计数;
计数++;
如果(x>y)
rec(x-y,y);
其他的
rec(x,y-x);
返回计数;
}
main(){
int i=0,j=2,n;
n=rec(i,j);
printf(“%d”,n);
}
需要N的值作为输出,程序不显示任何内容。是否确实不显示?您不输出换行符,因此它会在下一个命令行提示下被弄脏,因此很容易出错。当我运行它时,它会输出
0
。你确定这就是你实际运行的代码吗?