UVALive 6451:Tables(模拟 Grade D)
2024-08-24 11:28:35
题意:模拟输出表格
思路:模拟……很暴力
代码:
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <algorithm>
using namespace std; int graph[][]; int main() {
int n;
while (scanf("%d", &n) != EOF) {
if (n == ) break;
memset(graph, , sizeof(graph)); int maxcol = ;
for (int i = ; i < n; i++){
int m;
scanf("%d", &m);
for (int j = ; j < m; j++) {
int row, col;
scanf("%d%d", &row, &col);
int bgc = ;
while (graph[i][bgc] != ) bgc++;
col = bgc+col;
row = i+row;
int id = (i+)*+bgc+;
maxcol = max(maxcol, col);
for (int r = i; r < row; r++) {
for (int c = bgc; c < col; c++) {
graph[r][c] = id;
}
}
}
} //for (int i = 0; i < n; i++) {
// for (int j = 0; j < maxcol; j++) {
// printf("%d ", graph[i][j]);
// }puts("");
//}puts(""); for (int i = ; i < maxcol; i++) {
printf(" --");
}puts(""); for (int i = ; graph[i][]; i++) {
//Line
printf("|");
for (int j = ; graph[i][j]; j++) {
if (graph[i][j] == (i+)*+j+) printf("%d", graph[i][j]);
else printf(" ");
if (graph[i][j] == graph[i][j+]) printf(" ");
else printf("|");
}puts(""); //Button
int store = ;
for (int j = ; graph[i][j]; j++) {
if (graph[i][j] == graph[i+][j]) store++;
else {
while (store) {
printf(" ");
store--;
}
printf(" --");
}
}puts("");
}
puts("");
}
return ;
}
最新文章
- 在centos7中添加一个新用户,并授权
- Ubuntu 安装 CLI 并运行 ASP.NET Core 1.0
- Python爬虫Scrapy框架入门(0)
- 热更新脚本C#light,ulua,Scorpio性能比较
- BZOJ1036 树的统计
- MongoDB 权限
- 如何动态添加和删除一个div
- Linux开机自动挂载Windows分区
- JavaScript 插件的书页翻转效果
- 改造 vue-cli 脚手架
- 20175214 《Java程序设计》第8周学习总结
- javascript基础 之 void
- mongoDB2.6,java使用具体解释
- aiojobs
- TCP 基础知识
- pycharm 的包路径设置export PYTHONPATH=$PYTHONPATH
- java.lang.NoClassDefFoundError: Failed resolution of: Landroid/support/v4/animation/AnimatorCompatHelper
- ecshop,大商创后台设置增加字段方法
- 【thrift】thrift详解
- Centos7安装python3.7.1并与python2共存