UVALive 5797解题报告






The Braille system, designed by Louis Braille in 1825, revolutionized written communication for blind
and visually impaired persons. Braille, a blind Frenchman, developed a tactile language where each
element is represented by a cell with six dot positions, arranged in three rows and two columns. Each
dot position can be raised or not, allowing for 64 different con gurations which can be felt by trained
ngers. The gure below shows the Braille representation for the decimal digits (a black dot indicates
a raised position).
In order to develop a new software system to help teachers to deal with blind or visual impaired
students, a Braille dictionary module is necessary. Given a message, composed only by digits, your job
is to translate it to or from Braille. Can you help?

Input
Each test case is described using three or ve lines. The rst line contains an integer D representing
the number of digits in the message (1 D 100). The second line contains a single uppercase letter
`S' or `B'. If the letter is `S', the next line contains a message composed of D decimal digits that your
program must translate to Braille. If the letter is `B', the next three lines contain a message composed
of D Braille cells that your program must translate from Braille. Braille cells are separated by single
spaces. In each Braille cell a raised position is denoted by the character `*' (asterisk), while a not raised
position is denoted by the character `.' (dot).
The last test case is followed by a line containing one zero.

Output
For each test case print just the digits of the corresponding translation, in the same format as the input
(see the examples for further clari cation).

Sample Input
10
S
1234567890
3
B
*. *. **
.. *. ..
.. .. ..
2
S
00
0
Sample Output
*. *. ** ** *. ** ** *. .* .*
.. *. .. .* .* *. ** ** *. **
.. .. .. .. .. .. .. .. .. ..
123
.* .*
** **
.. ..


这题关键是要合理记录盲文信息 合理的方法会大大简化程序 此题并不难 就是有些麻烦的水题。

#include<iostream>
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<cmath>
#include<algorithm>
#include<stack>
#include<queue>
#include<vector>
#include<set>
#include<map>
using namespace std;


#define MAXN 10000 


char str[10][10]={"011100","100000","101000","110000","110100","100100","111000","111100","101100","011000"};  //6个点 6个记录 
char st[MAXN][10];
int main()
{
    
    int n;
    char a[MAXN],op[5];


    while(scanf("%d",&n)&&n)
    {
        scanf("%s",op);
        if(op[0]=='S')
        {
            scanf("%s",a);
            for(int i = 0; i < 3; i++)
            {
                for(int j = 0; a[j]; j++)
                {
                    int p=a[j]-'0';
                    
                    if(str[p][i*2]=='1') printf("*");//因为每行两个元素 所以乘以2 
                    else printf(".");
                    
                    if(str[p][i*2+1]=='1') printf("*");
                    else printf(".");
                    
                    if(j!=(int)strlen(a)-1)
                        printf(" ");
                }
                printf("\n");
            }


        }
        
        else
        {
            for(int i = 0; i < 3; i++)
            {
                a[0]='\0';
                while(a[0]=='\0') gets(a);   //一行一行来 
                for(int j = 0,k=0; a[j]; j+=3,k++)
                {


                    if(a[j]=='*') st[k][i*2]='1';
                    else st[k][i*2]='0';                //两个为一组记录字符 
                    
                    if(a[j+1]=='*') st[k][i*2+1]='1';  
                    else st[k][i*2+1]='0';
                }
            }
            
            for(int i = 0; i < n; i++)
            {
                st[i][6]='\0';
                for(int j = 0; j < 10; j++)
                {
                    if(strcmp(str[j],st[i])==0)
                    {
                        printf("%d",j);
                        break;
                    }
                }
            }
            printf("\n");
        }
    }
    return 0;
}

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值