zoukankan      html  css  js  c++  java
  • 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;
    }
  • 相关阅读:
    Linux中profile、bashrc、bash_profile之间的区别和联系
    指针长度长几何
    快速理解网络协议视频总结
    gdb调试关键点记录
    调试经验积累
    定位网页元素
    浮动
    盒子模型
    css3
    css
  • 原文地址:https://www.cnblogs.com/shinecheng/p/4004174.html
Copyright © 2011-2022 走看看