对了,能优化吗
查看原帖
对了,能优化吗
977778
__Harry_Haiyun__楼主2024/5/3 14:03
#include <bits/stdc++.h>
#define int long long
using namespace std;
int n,cnt = 1,i = 1,j;signed main()
{ios::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL);
    cin >> n;j = n;
    for (int k = 1; k <= n * n; k++)
{if 
	(cnt == i || cnt == j) printf("+");
	    	else printf("-");
cnt++;
	    if 
		(k % n == 0) 
		
		printf("\n"),cnt = 1,i++,j--;
	}
 	return 0;
}
2024/5/3 14:03
加载中...