hdu 2526

地址:http://acm.hdu.edu.cn/showproblem.php?pid=2526

题意:中文……下一行字符根据上一行对应三个字符来决定。

mark:无。

代码:

#include <stdio.h>
#include <string.h>

char a[2][510],b[8][4];
int f[8];

int tr(char c[])
{
    int i;
    for(i = 0; i < 8; i++)
        if(!strcmp(c, b[i])) return f[i];
}

int main()
{
    char c[4];
    int t,m,le;
    int i,j;
    scanf("%d", &t);
    while(t-- && scanf("%d", &m))
    {
        for(i = 0; i < 8; i++)
            scanf("%s %d", b[i], &f[i]);
        a[0][0] = a[1][0] = '0';
        scanf("%s", a[0]+1);
        puts(a[0]+1);
        le = strlen(a[0]);
        for(i = 1; i < m; i++)
        {
            for(j = 1; j < le; j++)
            {
                c[0] = a[!(i%2)][j-1];
                c[1] = a[!(i%2)][j];
                if(j == le-1) c[2] = '0';
                else c[2] = a[!(i%2)][j+1];
                c[3] = '\0';
                a[i%2][j] = tr(c)+'0';
            }
            puts(a[i%2]+1);
        }
    }
    return 0;
}

转载于:https://www.cnblogs.com/andre0506/archive/2012/07/01/2571840.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值