大哥帮小弟解俩题
| 1、九连宫问题 将1~9这九个数填在右图的 九个圆圈中,要求横、竖、对角线 之和均为15。 2、用递归方法求数组中的最小值。 3、求两个3ⅹ3矩阵转置后的乘积ATⅹBT。 |
| 1、九连宫问题 将1~9这九个数填在右图的 九个圆圈中,要求横、竖、对角线 之和均为15。 2、用递归方法求数组中的最小值。 3、求两个3ⅹ3矩阵转置后的乘积ATⅹBT。 |
2005-12-25 18:44

#include "stdio.h"
#include "conio.h"
#define N 10
int a[N]={102,45,25,78,69,49,68,33,2,67};
int function(int *p)
{
static temp = a;
temp = (temp>*(p+1))?*(p+1):temp;
p++;
if(p == a+N-1) return temp;
function(p);
}
void main()
{
printf("%d\n",function(a));
}
[此贴子已经被作者于2005-12-25 20:00:04编辑过]

2005-12-25 19:50
不能运行呀STATIC 是静态的,指针.
2005-12-26 07:59
2005-12-26 08:51
2005-12-26 10:27
#include "stdio.h"
#include "conio.h"
#define N 10
int a[N]={102,45,25,78,69,49,68,33,2,67};
int function(int *p)
{
static temp = a;
temp = (temp>*(p+1))?*(p+1):temp;
p++;
if(p == a+N-1) return temp;
function(p);
}
void main()
{
printf("%d\n",function(a));
}
2005-12-26 14:07
2005-12-26 14:08