#include<bits/stdc++.h>
using namespace std;
int main()
{
int n, i1 = 1, i, j, k;
string s;
while(cin >> n >> s)
{
if(n == 0 && s == "0")
break;
int m = 2*n+3;
int t = (m/2) + 1;
for(k=1;k<=m;k++)
{
if(k == 1)
{
for(i=0;i<s.size();i++)
{
if(i > 0)
cout << " ";
if(s[i] == '0' || s[i] == '2' || s[i] == '3' || s[i] == '5' || s[i] == '6' || s[i] == '7' || s[i] == '8' || s[i] == '9')
{
cout << " ";
for(j=1;j<=n;j++)
cout << "-";
cout << " ";
}
else
{
for(j=1;j<=n+2;j++)
cout << " ";
}
}
}
else if(k == t)
{
for(i=0;i<s.size();i++)
{
if(i > 0)
cout << " ";
if(s[i] == '2' || s[i] == '3' || s[i] == '4' || s[i] == '5' || s[i] == '6' || s[i] == '8' || s[i] == '9')
{
cout << " ";
for(j=1;j<=n;j++)
cout << "-";
cout << " ";
}
else
{
for(j=1;j<=n+2;j++)
cout << " ";
}
}
}
else if(k == m)
{
for(i=0;i<s.size();i++)
{
if(i > 0)
cout << " ";
if(s[i] == '0' || s[i] == '2' || s[i] == '3' || s[i] == '5' || s[i] == '6' || s[i] == '8' || s[i] == '9')
{
cout << " ";
for(j=1;j<=n;j++)
cout << "-";
cout << " ";
}
else
{
for(j=1;j<=n+2;j++)
cout << " ";
}
}
}
else if(k < t)
{
for(i=0;i<s.size();i++)
{
if(i > 0)
cout << " ";
if(s[i] == '1' || s[i] == '2' || s[i] == '3' || s[i] == '7')
{
for(j=1;j<=n+1;j++)
cout << " ";
cout << "|";
}
else if(s[i] == '4' || s[i] == '8' || s[i] == '9' || s[i] == '0')
{
cout << "|";
for(j=1;j<=n;j++)
{
cout << " ";
}
cout << "|";
}
else
{
cout << "|";
for(j=1;j<=n+1;j++)
cout << " ";
}
}
}
else
{
for(i=0;i<s.size();i++)
{
if(i > 0)
cout << " ";
if(s[i] == '1' || s[i] == '3' || s[i] == '4' || s[i] == '5' || s[i] == '7' || s[i] == '9')
{
for(j=1;j<=n+1;j++)
cout << " ";
cout << "|";
}
else if(s[i] == '0' || s[i] == '6' || s[i] == '8')
{
cout << "|";
for(j=1;j<=n;j++)
cout << " ";
cout << "|";
}
else if(s[i] == '2')
{
cout << "|";
for(j=1;j<=n+1;j++)
cout << " ";
}
}
}
cout << "\n";
}
cout << "\n";
}
return 0;
}
using namespace std;
int main()
{
int n, i1 = 1, i, j, k;
string s;
while(cin >> n >> s)
{
if(n == 0 && s == "0")
break;
int m = 2*n+3;
int t = (m/2) + 1;
for(k=1;k<=m;k++)
{
if(k == 1)
{
for(i=0;i<s.size();i++)
{
if(i > 0)
cout << " ";
if(s[i] == '0' || s[i] == '2' || s[i] == '3' || s[i] == '5' || s[i] == '6' || s[i] == '7' || s[i] == '8' || s[i] == '9')
{
cout << " ";
for(j=1;j<=n;j++)
cout << "-";
cout << " ";
}
else
{
for(j=1;j<=n+2;j++)
cout << " ";
}
}
}
else if(k == t)
{
for(i=0;i<s.size();i++)
{
if(i > 0)
cout << " ";
if(s[i] == '2' || s[i] == '3' || s[i] == '4' || s[i] == '5' || s[i] == '6' || s[i] == '8' || s[i] == '9')
{
cout << " ";
for(j=1;j<=n;j++)
cout << "-";
cout << " ";
}
else
{
for(j=1;j<=n+2;j++)
cout << " ";
}
}
}
else if(k == m)
{
for(i=0;i<s.size();i++)
{
if(i > 0)
cout << " ";
if(s[i] == '0' || s[i] == '2' || s[i] == '3' || s[i] == '5' || s[i] == '6' || s[i] == '8' || s[i] == '9')
{
cout << " ";
for(j=1;j<=n;j++)
cout << "-";
cout << " ";
}
else
{
for(j=1;j<=n+2;j++)
cout << " ";
}
}
}
else if(k < t)
{
for(i=0;i<s.size();i++)
{
if(i > 0)
cout << " ";
if(s[i] == '1' || s[i] == '2' || s[i] == '3' || s[i] == '7')
{
for(j=1;j<=n+1;j++)
cout << " ";
cout << "|";
}
else if(s[i] == '4' || s[i] == '8' || s[i] == '9' || s[i] == '0')
{
cout << "|";
for(j=1;j<=n;j++)
{
cout << " ";
}
cout << "|";
}
else
{
cout << "|";
for(j=1;j<=n+1;j++)
cout << " ";
}
}
}
else
{
for(i=0;i<s.size();i++)
{
if(i > 0)
cout << " ";
if(s[i] == '1' || s[i] == '3' || s[i] == '4' || s[i] == '5' || s[i] == '7' || s[i] == '9')
{
for(j=1;j<=n+1;j++)
cout << " ";
cout << "|";
}
else if(s[i] == '0' || s[i] == '6' || s[i] == '8')
{
cout << "|";
for(j=1;j<=n;j++)
cout << " ";
cout << "|";
}
else if(s[i] == '2')
{
cout << "|";
for(j=1;j<=n+1;j++)
cout << " ";
}
}
}
cout << "\n";
}
cout << "\n";
}
return 0;
}
Comments
Post a Comment