Run ID | 作者 | 问题 | 语言 | 测评结果 | Time | Memory | 代码长度 | 提交时间 |
---|---|---|---|---|---|---|---|---|
14643 | 胡彦祖 | 放大的X | C++ | Accepted | 85 MS | 744 KB | 715 | 2021-07-01 16:18:00 |
#include<bits/stdc++.h> using namespace std; int main(){ int n,m; int i,j,k; cin>>m; while(m--){ cin>>n; // 上半层层数 for(i=1;i<=n/2;i++){ // 左空格数 for(j=1; j<i; j++) cout<<' '; cout<<'X'; // 中间空格 for(k=1; k<=n-i*2; k++) cout<<' '; cout<<'X'; cout<<endl; } // 中间空格数量 for(k=1; k<=n/2; k++) cout<<' '; // 中间*号 cout<<'X'<<endl; // 下半层层数 for(i=1;i<=n/2;i++){ // 左空格数 for(j=1; j<=n/2-i; j++) cout<<' '; cout<<'X'; // 中间空格 for(k=1; k<=2*i-1; k++) cout<<' '; cout<<'X'; cout<<endl; } cout<<endl; } return 0; }