算法|搜索|问题1

以下程序的输出是什么?

null

#include <stdio.h>
void print( int n, int j)
{
if (j >= n)
return ;
if (n-j > 0 && n-j >= j)
printf ( "%d %d" , j, n-j);
print(n, j+1);
}
int main()
{
int n = 8;
print(n, 1);
}


(A) 1 7 2 6 3 5 4 4 4 4

(B) 1 7 2 6 3 5 4 4 (C) 1 7 2 6 3 5 (D) 1 2 3 4 5 6 7 8 答复: (B) 说明: 对于给定的数字n,程序打印所有不同的正整数对,其和等于n。 这个问题的小测验

© 版权声明
THE END
喜欢就支持一下吧
点赞7 分享