提交时间:2026-03-09 20:51:11

运行 ID: 431706

#include<bits/stdc++.h> using namespace std; int a[105][105]; // 存储矩阵,范围满足题目要求 int main(){ int n; cin >> n; // 读取矩阵大小 // 第一步:读取矩阵内容(移除多余的cout<<endl) for(int i=1; i<=n; i++){ for(int j=1; j<=n; j++){ cin >> a[i][j]; } } // 第二步:输出下三角部分(处理末尾空格问题) for(int i=1; i<=n; i++){ for(int j=1; j<=i; j++){ cout << a[i][j]; // 只有不是最后一个数时,才输出空格 if(j != i){ cout << " "; } } // 每行结束后换行 cout << endl; } return 0; }