#include "stdio.h"
#define N 10
#include<string.h>
void main()
{
int a[N][N];
int i,k,sum=0,sum1=0;
printf("请输入数值:\n");
for(i=0;i<N;i++)
{
for(k=0;k<N;k++)
{
a[i][k]=rand()%100;//随机产生0-100之间的数值并赋值给数组!
printf("%2d ",a[i][k]);
}
printf("\n");
}
for(i=0;i<N;i++)
sum+=a[i][i];
for(i=0;i<N;i++)
for(k=0;k<N;k++)
if(i+k==N-1)
sum1+=a[i][k];
printf("正斜对角线的和为:%d\n反斜对角线的和为:%d\n两条对角线的和为:%d",sum,sum1,sum+sum1);
}