ZZULIOJ--1231: 画棋盘

时间限制: 1 Sec 内存限制: 128 MB
提交: 613 解决: 275
[状态] [提交] [命题人:外部导入]
题目描述
这是一个很简单的问题,喜欢下棋的你对棋盘的研究多么, 在这里希望你能够用数字0和空格字符画出N*N的棋盘.

输入
多组测试实例。
每组测试输入一个整数N, 1 <= N<= 100.

输出
要求输出N*N的棋盘,最小的单元格里是一个空格,每一行没有多余的空格。
每两组测试实例中间有一空行。

样例输入 Copy
1
3

样例输出 Copy
000
0 0
000

0000000
0 0 0 0
0000000
0 0 0 0
0000000
0 0 0 0
0000000
这道题目和之前的1224:画表格类似,甚至是一道题,有个易错点是题目要求输出之间要有空一行,比较容易忽略

#include <iostream>
#include <cstdio>
#include <fstream>
#include <algorithm>
#include <cmath>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <stack>
#include <vector>
#include <string>
#include <cstring>
using namespace std;
int main()
{
	int n;
	while(~scanf("%d",&n)){
		for(int p=0;p<n;p++){
		
		for(int i=0;i<n;i++){
			printf("00");
		}
		printf("0\n");
		for(int j=0;j<n;j++){
			printf("0 ");
		}
		printf("0\n");
	}
	for(int q=0;q<n;q++){
		printf("00");
		
	}
	printf("0\n");
	printf("\n");  //输出空一行

}
	return 0;
	
}
发布了6 篇原创文章 · 获赞 1 · 访问量 55

猜你喜欢

转载自blog.csdn.net/CoIorful/article/details/104108730
今日推荐