Bootstrap

每日一题洛谷B3865 [GESP202309 二级] 小杨的 X 字矩阵c++

#include<iostream>
#include<string>
using namespace std;
int main() {
	int n;
	cin >> n;
	string s[50][50] = {" "};
	for (int i = 1; i <= n; i++) {
		for (int j = 1; j <= n; j++) {
			s[i][j] = "-";
		}
		s[i][i] = "+";
		s[i][n + 1 - i] = "+";
	}
	for (int i = 1; i <= n; i++) {
		for (int j = 1; j <= n; j++) {
			cout << s[i][j];
		}
		cout << endl;
	}
	return 0;
}

;