/* 8 2 1 4 7 9 8 6 2 9 7 10 sum = 60 Press any key to continue */ #include #include #include #define M 4 #define N 3 int main() { int a[M][N],i,j,sum = 0; srand(time(NULL)); for(i = 0; i < M; ++i) { for(j = 0; j < N; ++j) { a[i][j] = rand() % 10 + 1; printf("%5d",a[i][j]); } printf("\n"); } for(i = 0; i < N; ++i) sum += a[0][i] + a[M - 1][i]; for(i = 1; i < M - 1; ++i) sum += a[i][0] + a[i][M - 2]; printf("sum = %d\n",sum); return 0; }