题目链接
转眼就到了2018年的ACM集训队第二次招新,希望大家在本次比赛中取得好成绩!
看标题名字就知道,历史总是惊人的相似,这个题目和上次招新赛的某道题很像,还是关于A+B问题的,题目是这样的:
给出你一个表达式只包含’+’,’-'两种运算,然后你要输出对应结果的字符画形式。
给出的表达式形式一定是形如:
‘a+b’,‘a-b’,这种形式,并且保证a和b的范围都在0~9之内.
具体的输入和输出可以通过观察样例得到。
…# ##### ##### #…# ##### ##### ##### ##### ##### … … …
#…# …# …# …# #…# #… #… …# #…# #…# …#… … …
#…# …# …# …# #…# #… #… …# #…# #…# …#… … #####
#…# …# ##### ##### ##### ##### ##### …# ##### ##### ##### ##### …
#…# …# #… …# …# …# #…# …# #…# …# …#… … #####
#…# …# #… …# …# …# #…# …# #…# …# …#… … …
…# ##### ##### …# ##### ##### …# ##### ##### … … …
输入描述:
第一行包含一个整数T,代表有T组输入数据
对于每组数据,包含一个表达式,如:
3-5
1+4
0-0
输出描述:
对于每一个表达式,输出对应的字符画,输出方式可以观察样例得到。
对于每组数据,输出一个换行.
样例输入:
4
3-5
9-9
9+9
0-0
样例输出:
#####…#####…#####
…#…#…#
…#…#…#####…#
#####.#####.#####…#####.#####
…#…#.#####…#…
…#…#…#…
#####…#####…#####
#####…#####…#####
#…#…#…#…#…#
#…#…#…#.#####.#…#
#####.#####.#####…#…#
…#…#.#####.#…#
…#…#…#…#
#####…#####…#####
#####…#####…#.#####
#…#…#…#…#…#.#…#
#…#…#…#…#.#####…#.#…#
#####.#####.#####…#.#####
…#…#…#.#####…#.#…#
…#…#…#…#.#…#
#####…#####…#.#####
#####…#####…#####
#…#…#…#…#…#
#…#…#…#.#####.#…#
#…#.#####.#…#…#…#
#…#…#…#.#####.#…#
#…#…#…#…#…#
#####…#####…#####
提示:
注意输出的时候,每个数之间有一排’.’
来源:
riba2534
上传者:riba2534
#include <stdio.h>
#include <algorithm>
#include<string>
#include<string.h>
#include<iostream>
#include<queue>
using namespace std;
#define ll long long
string s[10];
string kk[10];
void aa(int x,int i)
{
if(x==0) kk[i]+=s[i].substr(0,5);
else if(x==1) kk[i]+=s[i].substr(5,5);
else if(x==2) kk[i]+=s[i].substr(10,5);
else if(x==3) kk[i]+=s[i].substr(15,5);
else if(x==4) kk[i]+=s[i].substr(20,5);
else if(x==5) kk[i]+=s[i].substr(25,5);
else if(x==6) kk[i]+=s[i].substr(30,5);
else if(x==7) kk[i]+=s[i].substr(35,5);
else if(x==8) kk[i]+=s[i].substr(40,5);
else if(x==9) kk[i]+=s[i].substr(45,5);
else if(x==10) kk[i]+=s[i].substr(50,5);
else if(x==11) kk[i]+=s[i].substr(55,5);
else if(x==12) kk[i]+=s[i].substr(60,5);
}
char ss[10];
int a,b,c,d,t,k,p;
int main()
{
s[1]="#####....############...##########################...............";
s[2]="#...#....#....#....##...##....#........##...##...#..#............";
s[3]="#...#....#....#....##...##....#........##...##...#..#.......#####";
s[4]="#...#....##########################....#####################.....";
s[5]="#...#....##........#....#....##...#....##...#....#..#.......#####";
s[6]="#...#....##........#....#....##...#....##...#....#..#............";
s[7]="#####....###########....###########....###########...............";
//// 0 45 9
scanf("%d",&t);
while(t--)
{
for(int i=1;i<=7;i++) kk[i].clear();
p=0;
scanf("%s",ss);
d=-1;
a=ss[0]-'0';
b=ss[2]-'0';
if(ss[1]=='+') c=a+b,k=10;
else c=a-b,k=11;
if(c<0) c=-c,p=1;
if(c>=10) d=c-10,c=1;
for(int i=1;i<=7;i++)
{
aa(a,i);kk[i]+='.';
aa(k,i);kk[i]+='.';
aa(b,i);kk[i]+='.';
aa(12,i);kk[i]+='.';
if(p) {aa(11,i);kk[i]+='.';}
aa(c,i);
if(d>-1) {kk[i]+='.';aa(d,i);}
}
for(int i=1;i<=7;i++)
cout<<kk[i]<<endl;
printf("\n");
}
}