基本思想:
没啥思想,弱智题,关键是注意,m和n为0的用例情况;
关键点:
无;
#include<iostream> #include<stdlib.h> #include<stdio.h> #include<vector> #include<string> #include<math.h> #include<algorithm> #include<cstring> using namespace std; int main(){ int n, m; cin >> m >> n; if (n == 0 || m == 0) return 1; for (int i = 0; i < m+m+1; i++) { if (i % 2 == 0) { for (int j = 0; j < n + n + 1; j++) { if (j % 2 == 0) { cout << "+"; } else { cout << "-"; } } cout << endl; } else { for (int j = 0; j < n + n + 1; j++) { if (j % 2 == 0) { cout << "|"; } else { cout << " "; } } cout << endl; } } return 0; }
蓝桥杯 1537: [蓝桥杯][算法提高VIP]栅格打印问题
原文:https://www.cnblogs.com/songlinxuan/p/12291287.html