题解
2026-05-12 20:30:12
发布于:湖北
7阅读
0回复
0点赞
打印字符矩阵
#include<iostream>
using namespace std;
int main(){
int n;
cin>>n;
for(int i=1;i<=n;i++){
for(int j=1;j<=n;j++){
if((i==j)||(i+j==n+1)){ //对角线的规律
cout<<"+";
}
else {
cout << "-";
}
}
cout<<endl; //位置要对
}
return 0;
}
这里空空如也







有帮助,赞一个