首页 > 编程语言 > 详细

蓝桥杯 1537: [蓝桥杯][算法提高VIP]栅格打印问题

时间:2020-02-10 16:32:59      阅读:69      评论:0      收藏:0      [点我收藏+]

基本思想:

没啥思想,弱智题,关键是注意,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

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!