• UVa 512


    水题
    感觉操作数组删行添行比较麻烦
    可以把操作步骤存储下来, 每次搜索时逐步操作即可

    #include <iostream>
    #include <cstring>
    #include <cstdio>
    
    using namespace std;
    
    const int maxn = 60;
    
    struct command{
        char c[5];  //操作名称
        int t;
        int mrk[100];
    };
    
    int main()
    {
        int a,b;
        int num = 0;
        struct command com[100];
        while( scanf("%d%d",&a,&b) && a )
        {
            if(++num != 1)  puts("");
            printf("Spreadsheet #%d
    ",num);
            int T;
            scanf("%d",&T);
            for( int i = 0; i < T; i++ )
            {
                scanf("%s",com[i].c);
                if( com[i].c[0] == 'E' ){
                    com[i].t = 4;
                    for( int j = 0; j < com[i].t; j++ )
                        scanf("%d",&com[i].mrk[j]);
                }
                else{
                    scanf("%d",&com[i].t);
                    for( int j = 0; j < com[i].t; j++ )
                        scanf("%d",&com[i].mrk[j]);
                }
            }
            int TT;
            scanf("%d",&TT);
            int x, y;
            while( TT-- )
            {
                scanf("%d%d",&x,&y);
                int x0 = x, y0 = y;
                for( int i = 0; i < T; i++ )
                {
                    int sum = 0;
                    if( com[i].c[0] == 'E' ){
                        if( ( x == com[i].mrk[0] && y == com[i].mrk[1] ) ){
                            x = com[i].mrk[2];
                            y = com[i].mrk[3];
                        }
                        else if( ( x == com[i].mrk[2] && y == com[i].mrk[3] ) ){
                            x = com[i].mrk[0];
                            y = com[i].mrk[1];
                        }
                    }
                    if( strcmp( com[i].c, "DR" ) == 0 ){
                        for( int j = 0; j < com[i].t; j++ ){
                            if( x > com[i].mrk[j] )     sum++;
                            else if( x == com[i].mrk[j] )   sum = x;
                        }
                        x -= sum;
                        if( x <= 0 )    break;
                    }
                    if( strcmp( com[i].c, "DC" ) == 0 ){
                        for( int j = 0; j < com[i].t; j++ ){
                            if( y > com[i].mrk[j] )     sum++;
                            else if( y == com[i].mrk[j] )   sum = y;
                        }
                        y -= sum;
                        if( y <= 0 )    break;
                    }
                    if( strcmp( com[i].c, "IR" ) == 0 ){
                        for( int j = 0; j < com[i].t; j++ )
                            if( x >= com[i].mrk[j] )     sum++;
                        x += sum;
                    }
                    if( strcmp( com[i].c, "IC" ) == 0 ){
                        for( int j = 0; j < com[i].t; j++ )
                            if( y >= com[i].mrk[j] )     sum++;
                        y += sum;
                    }
                }
                printf("Cell data in (%d,%d) ",x0,y0);
                if( x <= 0 || y <= 0 )  puts("GONE");
                else    printf("moved to (%d,%d)
    ",x,y);
            }
        }
        return 0;
    }
  • 相关阅读:
    MySql数据类型详解
    MySQL日期数据类型、MySQL时间类型使用总结
    sqlcmd
    sqlserver 复制
    Do waiting or suspended tasks tie up a worker thread?
    用GDB 调试Java程序
    X64相关文章
    How do I find what queries were executing in a SQL memory dump?-----stack
    解决Sublime Text 3中文显示乱码(tab中文方块)问题
    GIT 详解
  • 原文地址:https://www.cnblogs.com/JinxiSui/p/9740640.html
Copyright © 2020-2023  润新知