输入5*5的数组,编写程序求出对角线上各元素之和

2024-12-04 21:37:36
推荐回答(1个)
回答1:

#include
#define N 5
void main() { int i,j,a[N][N],sum1,sum2;
for ( i=0;isum1=sum2=0; for ( i=0;iprintf("正对角线元素和%d,反对角线元素和%d\n",sum1,sum2);
}