首页 > 代码库 > UVALive 6451:Tables(模拟 Grade D)
UVALive 6451:Tables(模拟 Grade D)
VJ题目链接
题意:模拟输出表格
思路:模拟……很暴力
代码:
#include <cstdio>#include <cstring>#include <cstdlib>#include <algorithm>using namespace std;int graph[100][100];int main() { int n; while (scanf("%d", &n) != EOF) { if (n == 0) break; memset(graph, 0, sizeof(graph)); int maxcol = 0; for (int i = 0; i < n; i++){ int m; scanf("%d", &m); for (int j = 0; j < m; j++) { int row, col; scanf("%d%d", &row, &col); int bgc = 0; while (graph[i][bgc] != 0) bgc++; col = bgc+col; row = i+row; int id = (i+1)*10+bgc+1; 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 = 0; i < maxcol; i++) { printf(" --"); }puts(""); for (int i = 0; graph[i][0]; i++) { //Line printf("|"); for (int j = 0; graph[i][j]; j++) { if (graph[i][j] == (i+1)*10+j+1) printf("%d", graph[i][j]); else printf(" "); if (graph[i][j] == graph[i][j+1]) printf(" "); else printf("|"); }puts(""); //Button int store = 0; for (int j = 0; graph[i][j]; j++) { if (graph[i][j] == graph[i+1][j]) store++; else { while (store) { printf(" "); store--; } printf(" --"); } }puts(""); } puts(""); } return 0;}
UVALive 6451:Tables(模拟 Grade D)
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。