#define _CRT_SECURE_NO_WARNINGS #include <Windows.h> #include <stdio.h> #include <stdlib.h> void main() { int n = 0; scanf("%d", &n); int a[50][50] = { 0 }; int result = 0; for (int i = 0; i < n * n; i++) { a[i / n][i % n] = i + 1; if ((i % n) == 0){ result += a[i / n][i % n] + (i / n); } } for (int i = 0; i < n; i++) { for (int j = 0; j < n; j++) { printf("%-6d", a[i][j]); } printf("\n"); } printf("result=%d", result); getchar(); getchar(); }
时间: 2024-10-05 04:27:41