码迷,mamicode.com
首页 > 其他好文 > 详细

Gym - 101480A_ASCII Addition

时间:2018-10-11 11:29:55      阅读:212      评论:0      收藏:0      [点我收藏+]

标签:stream   ++   asc   main   queue   printf   space   问题   tac   

题目链接

技术分享图片

技术分享图片

题解:普通的a+b才怪问题,需要绘制出来,方法有点麻烦。

#include <iostream>
#include <string.h>
#include <stdlib.h>
#include <stdio.h>
#include <queue>
#include <stack>
#include <stack>

using namespace std;

char s[10][200],s2[10][200];
char num[7][11][6] = {
"xxxxx","....x","xxxxx","xxxxx","x...x","xxxxx","xxxxx","xxxxx","xxxxx","xxxxx",".....",
"x...x","....x","....x","....x","x...x","x....","x....","....x","x...x","x...x","..x..",
"x...x","....x","....x","....x","x...x","x....","x....","....x","x...x","x...x","..x..",
"x...x","....x","xxxxx","xxxxx","xxxxx","xxxxx","xxxxx","....x","xxxxx","xxxxx","xxxxx",
"x...x","....x","x....","....x","....x","....x","x...x","....x","x...x","....x","..x..",
"x...x","....x","x....","....x","....x","....x","x...x","....x","x...x","....x","..x..",
"xxxxx","....x","xxxxx","xxxxx","....x","xxxxx","xxxxx","....x","xxxxx","xxxxx","....."};
int f[15];

void cmp(int l,int r,int x)
{
    int i,j;
    for(i=0;i<=10;i++)
    {
        if(!f[i])
            continue;
        for(j=0;j<5;j++)
        {
            if(s[x][l+j]!=num[x][i][j])
                break;
        }
        if(j!=5)
            f[i] = 0;
    }
}

int read(int l,int r)
{
    int i;
    for(i=0;i<=10;i++)
        f[i] = 1;
    for(i=0;i<7;i++)
        cmp(l,r,i);
    for(i=0;i<=10;i++)
    {
        if(f[i])
            return i;
    }
    return -1;
}

long long c;

void show(long long x,int a)
{
    if(x>=10)
        show(x/10,a);
    if(x!=c)
        printf("%s.",num[a][x%10]);
    else
        printf("%s\n",num[a][x%10]);
}

int main()
{
    int i;
    long long a,b,n,sum;
    for(i=0;i<7;i++)
        scanf("%s",s[i]);
    n = strlen(s[0]);
    a = b = 0;
    sum = 0;
    for(i=0;i<n;i+=6)
    {
        c = read(i,i+5);
        if(c==10)
        {
            a = sum;
            sum = 0;
        }
        else
        {
            sum *= 10;
            sum += c;
        }
    }
    b = sum;
    c = a + b;
    for(i=0;i<7;i++)
        show(c,i);
    return 0;
}

Gym - 101480A_ASCII Addition

标签:stream   ++   asc   main   queue   printf   space   问题   tac   

原文地址:https://www.cnblogs.com/luoxiaoyi/p/9770950.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!