user-0 提问: 递归法比较最大值

回复:
user: user-1
content: 没什么问题 要么需要加个getchar(); 要么大概是大括号没加

user: user-2
content: 没啥问题，程序好着呢！

user: user-3
content: 这不就是把循环改成尾递归么。

user: user-4
content: 引用 3 楼 tsakang 的回复:没啥问题，程序好着呢！  lz 发现什么问题？

user: user-5
content: main.c  #include <stdio.h>  int getMax(int a[], int n, int max) { 	if (n <= 0) return max; 	return getMax(a, n-1, max > a[n-1] ? max : a[n-1]);  }  int main(void) { 	//int getMax(int a[],int n,int max); 	int a[][4] = { 		{1, 1, 1, 1}, 		{1, 1, 1, 2}, 		{1, 1, 1, 3}, 		{1, 1, 1, 4}, 		{1, 1, 2, 1}, 		{1, 1, 2, 2}, 		{1, 1, 2, 3}, 		{1, 1, 2, 4}, 		{1, 1, 3, 1}, 		{1, 1, 3, 2}, 		{1, 1, 3, 3}, 		{1, 1, 3, 4}, 		{1, 1, 4, 1}, 		{1, 1, 4, 2}, 		{1, 1, 4, 3}, 		{1, 1, 4, 4}, 		{1, 2, 1, 1}, 		{1, 2, 1, 2}, 		{1, 2, 1, 3}, 		{1, 2, 1, 4}, 		{1, 2, 2, 1}, 		{1, 2, 2, 2}, 		{1, 2, 2, 3}, 		{1, 2, 2, 4}, 		{1, 2, 3, 1}, 		{1, 2, 3, 2}, 		{1, 2, 3, 3}, 		{1, 2, 3, 4}, 		{1, 2, 4, 1}, 		{1, 2, 4, 2}, 		{1, 2, 4, 3}, 		{1, 2, 4, 4}, 		{1, 3, 1, 1}, 		{1, 3, 1, 2}, 		{1, 3, 1, 3}, 		{1, 3, 1, 4}, 		{1, 3, 2, 1}, 		{1, 3, 2, 2}, 		{1, 3, 2, 3}, 		{1, 3, 2, 4}, 		{1, 3, 3, 1}, 		{1, 3, 3, 2}, 		{1, 3, 3, 3}, 		{1, 3, 3, 4}, 		{1, 3, 4, 1}, 		{1, 3, 4, 2}, 		{1, 3, 4, 3}, 		{1, 3, 4, 4}, 		{1, 4, 1, 1}, 		{1, 4, 1,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 4, 3}, 		{4, 4, 4, 4} 	}; 	int n, i, max;  	//printf("请输入四个数:"); 	//for (n = 0; n < 4; n++) 	//	scanf("%d", &a[n]); 	//for (n = 0; n < 4; n++) 	//	printf("%d ", a[n]);  	for (n = 0; n < 256; n++) { 		//printf("这4个数的最大值为:%d\n", getMax(a, 4, a[0])); 		printf("MAX["); 		for (i = 0; i < 4; i++) 		{ 			if (i != 3) 				printf("%d,", a[n][i]); 			else 				printf("%d", a[n][i]); 		} 		printf("] = "); 		printf("%d\n", getMax(a[n], 4, a[n][0])); 		//printf("这4个数的最大值为:%d\n", getMax(a[n], 4, a[n][0])); 	}  	getch(); 	return 0; }  输出： MAX[1,1,1,1] = 1 MAX[1,1,1,2] = 2 MAX[1,1,1,3] = 3 MAX[1,1,1,4] = 4 MAX[1,1,2,1] = 2 MAX[1,1,2,2] = 2 MAX[1,1,2,3] = 3 MAX[1,1,2,4] = 4 MAX[1,1,3,1] = 3 MAX[1,1,3,2] = 3 MAX[1,1,3,3] = 3 MAX[1,1,3,4] = 4 MAX[1,1,4,1] = 4 MAX[1,1,4,2] = 4 MAX[1,1,4,3] = 4 MAX[1,1,4,4] = 4 MAX[1,2,1,1] = 2 MAX[1,2,1,2] = 2 MAX[1,2,1,3] = 3 MAX[1,2,1,4] = 4 MAX[1,2,2,1] = 2 MAX[1,2,2,2] = 2 MAX[1,2,2,3] = 3 MAX[1,2,2,4] = 4 MAX[1,2,3,1] = 3 MAX[1,2,3,2] = 3 MAX[1,2,3,3] = 3 MAX[1,2,3,4] = 4 MAX[1,2,4,1] = 4 MAX[1,2,4,2] = 4 MAX[1,2,4,3] = 4 MAX[1,2,4,4] = 4 MAX[1,3,1,1] = 3 MAX[1,3,1,2] = 3 MAX[1,3,1,3] = 3 MAX[1,3,1,4] = 4 MAX[1,3,2,1] = 3 MAX[1,3,2,2] = 3 MAX[1,3,2,3] = 3 MAX[1,3,2,4] = 4 MAX[1,3,3,1] = 3 MAX[1,3,3,2] = 3 MAX[1,3,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3,3] = 4 MAX[4,3,3,4] = 4 MAX[4,3,4,1] = 4 MAX[4,3,4,2] = 4 MAX[4,3,4,3] = 4 MAX[4,3,4,4] = 4 MAX[4,4,1,1] = 4 MAX[4,4,1,2] = 4 MAX[4,4,1,3] = 4 MAX[4,4,1,4] = 4 MAX[4,4,2,1] = 4 MAX[4,4,2,2] = 4 MAX[4,4,2,3] = 4 MAX[4,4,2,4] = 4 MAX[4,4,3,1] = 4 MAX[4,4,3,2] = 4 MAX[4,4,3,3] = 4 MAX[4,4,3,4] = 4 MAX[4,4,4,1] = 4 MAX[4,4,4,2] = 4 MAX[4,4,4,3] = 4 MAX[4,4,4,4] = 4  没发现什么问题。

user: user-6
content: //scanf前面加一个空格 scanf(" %d",&a[n]); //或者 加一个    getchar();  //其他还有什么问题