试了n种方法,包括题解,都不对,求助!
#include<iostream>
#include<string>
#include<cmath>
using namespace std;
typedef long long ll;
int main()
{
int n;
cin>>n;
for(int i=0;i<n;i++)
{
for(int j=0;j<n;j++)
{
if(i==j||i + j == n + 1) cout<<"+";
else cout<<"-";
}
cout<<endl;
}
return 0;
}
输入5,输出
+----
-+---
--+-+
---+-
--+-+