Run ID:158539

提交时间:2026-08-22 14:32:50

#include <iostream> using namespace std; int main() { int T; cin >> T; while (T--) { int n; cin >> n; for (int i = 0; i < n; i++) { for (int j = 0; j < n; j++) { // 主对角线 i==j 、副对角线 i+j == n‑1 的位置输出X if (i == j || i + j == n - 1) cout << 'X'; else cout << ' '; } cout << endl; } cout << endl; //每组后面空一行 } return 0; }