//你这题和你的代码 八竿子达不到边啊,你想表达什么意思啊。。。我把边上的数字全去掉了
#include
using namespace std;
void main()
{
int n=0,sum=0;
while(1)
{
cout<<"输入一个正整数:"<
if (n>0)
break;
}
int **elements=NULL;//二维指针
elements=new int * [n];
if(NULL==elements)
exit(1);
int i,j;
for (i = 0; i < n; i++)
{
elements[i] = new int [n];
if (NULL==elements[i])
exit(1);
}
for (i = 0; i < n; i++)
for (j = 0; j
if(i>0 && i
}
for (i = 0; i < n-2; i++)
{
for (j = 0; j
sum+=elements[i][i];
printf("\n");
}
printf("trace is %d\n",sum);
for (i = 0; i < n; i++)
free(elements[i]);
free(elements);
}