Thanks Raiyan Kamal, that was now accepted.
Posted: Mon Mar 28, 2005 8:16 pm
Yes, i changed my code to handle leading zero printing. and got accepted (PE) result from the judge. I'll correct the PE later. But any way thanks.
thanx a lot for the hints kiha, i was wondering why i got a RTE SIGSEGV, now i know that i didnt handle other input which was not '0' - '9'kiha wrote: ...
...
1) if you write in Pascal [I don't know how is it like in C/C++] and remember the number as a string , be careful if the last character of this string is a white space
...
...
Good luck to you solvers
Code: Select all
var
sto:array[1..1000000] of string;
pe:array[1..1000000] of integer;
inp:string;
p,i,j,m,a,n:longint;
ans:array[1..100000] of string;
procedure one(s:integer);
var
x,y:integer;
begin
for x:=1 to s+2 do
ans[1]:=concat(ans[1], ' ');
for x:=2 to s+1 do
begin
for y:=1 to s+1 do
ans[x]:=concat(ans[x], ' ');
ans[x]:=concat(ans[x], '|');
end;
for x:=1 to s+2 do
ans[s+2]:=concat(ans[s+2], ' ');
for x:=s+3 to s+2+s do
begin
for y:=1 to s+1 do
ans[x]:=concat(ans[x], ' ');
ans[x]:=concat(ans[x], '|');
end;
for x:=1 to s+2 do
ans[s+s+3]:=concat(ans[s+s+3], ' ');
end;
procedure two(s:integer);
var
x,y:integer;
begin
ans[1]:=concat(ans[1], ' ');
for x:=1 to s do
ans[1]:=concat(ans[1], '-');
ans[1]:=concat(ans[1], ' ');
for x:=2 to s+1 do
begin
for y:=1 to s+1 do
ans[x]:=concat(ans[x], ' ');
ans[x]:=concat(ans[x], '|');
end;
ans[s+2]:=concat(ans[s+2], ' ');
for x:=1 to s do
ans[s+2]:=concat(ans[s+2], '-');
ans[s+2]:=concat(ans[s+2], ' ');
for x:=s+3 to s+s+2 do
begin
ans[x]:=concat(ans[x], '|');
for y:=1 to s+1 do
ans[x]:=concat(ans[x], ' ');
end;
ans[s+s+3]:=concat(ans[s+s+3], ' ');
for x:=1 to s do
ans[s+s+3]:=concat(ans[s+s+3], '-');
ans[s+s+3]:=concat(ans[s+s+3], ' ');
end;
procedure three(s:integer);
var
x,y:integer;
begin
ans[1]:=concat(ans[1], ' ');
for x:=1 to s do
ans[1]:=concat(ans[1], '-');
ans[1]:=concat(ans[1], ' ');
for x:=2 to s+1 do
begin
for y:=1 to s+1 do
ans[x]:=concat(ans[x], ' ');
ans[x]:=concat(ans[x], '|');
end;
ans[s+2]:=concat(ans[s+2], ' ');
for x:=1 to s do
ans[s+2]:=concat(ans[s+2], '-');
ans[s+2]:=concat(ans[s+2], ' ');
for x:=s+3 to s+s+2 do
begin
for y:=1 to s+1 do
ans[x]:=concat(ans[x], ' ');
ans[x]:=concat(ans[x], '|');
end;
ans[s+s+3]:=concat(ans[s+s+3], ' ');
for x:=1 to s do
ans[s+s+3]:=concat(ans[s+s+3], '-');
ans[s+s+3]:=concat(ans[s+s+3], ' ');
end;
procedure four(s:integer);
var
x,y:integer;
begin
for x:=1 to s+2 do
ans[1]:=concat(ans[1], ' ');
for x:=2 to s+1 do
begin
ans[x]:=concat(ans[x], '|');
for y:=1 to s do
ans[x]:=concat(ans[x], ' ');
ans[x]:=concat(ans[x], '|');
end;
ans[s+2]:=concat(ans[s+2], ' ');
for x:=1 to s do
ans[s+2]:=concat(ans[s+2], '-');
ans[s+2]:=concat(ans[s+2], ' ');
for x:=s+3 to s+s+2 do
begin
for y:=1 to s+1 do
ans[x]:=concat(ans[x], ' ');
ans[x]:=concat(ans[x], '|');
end;
for x:=1 to s+2 do
ans[s+s+3]:=concat(ans[s+s+3], ' ');
end;
procedure five(s:integer);
var
x,y:integer;
begin
ans[1]:=concat(ans[1], ' ');
for x:=1 to s do
ans[1]:=concat(ans[1], '-');
ans[1]:=concat(ans[1], ' ');
for x:=2 to s+1 do
begin
ans[x]:=concat(ans[x], '|');
for y:=1 to s+1 do
ans[x]:=concat(ans[x], ' ');
end;
ans[s+2]:=concat(ans[s+2], ' ');
for x:=1 to s do
ans[s+2]:=concat(ans[s+2], '-');
ans[s+2]:=concat(ans[s+2], ' ');
for x:=s+3 to s+s+2 do
begin
for y:=1 to s+1 do
ans[x]:=concat(ans[x], ' ');
ans[x]:=concat(ans[x], '|');
end;
ans[s+s+3]:=concat(ans[s+s+3], ' ');
for x:=1 to s do
ans[s+s+3]:=concat(ans[s+s+3], '-');
ans[s+s+3]:=concat(ans[s+s+3], ' ');
end;
procedure six(s:integer);
var
x,y:integer;
begin
ans[1]:=concat(ans[1], ' ');
for x:=1 to s do
ans[1]:=concat(ans[1], '-');
ans[1]:=concat(ans[1], ' ');
for x:=2 to s+1 do
begin
ans[x]:=concat(ans[x], '|');
for y:=1 to s+1 do
ans[x]:=concat(ans[x], ' ');
end;
ans[s+2]:=concat(ans[s+2], ' ');
for x:=1 to s do
ans[s+2]:=concat(ans[s+2], '-');
ans[s+2]:=concat(ans[s+2], ' ');
for x:=s+3 to s+s+2 do
begin
ans[x]:=concat(ans[x], '|');
for y:=1 to s do
ans[x]:=concat(ans[x], ' ');
ans[x]:=concat(ans[x], '|');
end;
ans[s+s+3]:=concat(ans[s+s+3], ' ');
for x:=1 to s do
ans[s+s+3]:=concat(ans[s+s+3], '-');
ans[s+s+3]:=concat(ans[s+s+3], ' ');
end;
procedure seven(s:integer);
var
x,y:integer;
begin
ans[1]:=concat(ans[1], ' ');
for x:=1 to s do
ans[1]:=concat(ans[1], '-');
ans[1]:=concat(ans[1], ' ');
for x:=2 to s+1 do
begin
for y:=1 to s+1 do
ans[x]:=concat(ans[x], ' ');
ans[x]:=concat(ans[x], '|');
end;
for x:=1 to s+2 do
ans[s+2]:=concat(ans[s+2], ' ');
for x:=s+3 to s+2+s do
begin
for y:=1 to s+1 do
ans[x]:=concat(ans[x], ' ');
ans[x]:=concat(ans[x], '|');
end;
for x:=1 to s+2 do
ans[s+s+3]:=concat(ans[s+s+3], ' ');
end;
procedure eight(s:integer);
var
x,y:integer;
begin
ans[1]:=concat(ans[1], ' ');
for x:=1 to s do
ans[1]:=concat(ans[1], '-');
ans[1]:=concat(ans[1], ' ');
for x:=2 to s+1 do
begin
ans[x]:=concat(ans[x], '|');
for y:=1 to s do
ans[x]:=concat(ans[x], ' ');
ans[x]:=concat(ans[x], '|');
end;
ans[s+2]:=concat(ans[s+2], ' ');
for x:=1 to s do
ans[s+2]:=concat(ans[s+2], '-');
ans[s+2]:=concat(ans[s+2], ' ');
for x:=s+3 to s+s+2 do
begin
ans[x]:=concat(ans[x], '|');
for y:=1 to s do
ans[x]:=concat(ans[x], ' ');
ans[x]:=concat(ans[x], '|');
end;
ans[s+s+3]:=concat(ans[s+s+3], ' ');
for x:=1 to s do
ans[s+s+3]:=concat(ans[s+s+3], '-');
ans[s+s+3]:=concat(ans[s+s+3], ' ');
end;
procedure nine(s:integer);
var
x,y:integer;
begin
ans[1]:=concat(ans[1], ' ');
for x:=1 to s do
ans[1]:=concat(ans[1], '-');
ans[1]:=concat(ans[1], ' ');
for x:=2 to s+1 do
begin
ans[x]:=concat(ans[x], '|');
for y:=1 to s do
ans[x]:=concat(ans[x], ' ');
ans[x]:=concat(ans[x], '|');
end;
ans[s+2]:=concat(ans[s+2], ' ');
for x:=1 to s do
ans[s+2]:=concat(ans[s+2], '-');
ans[s+2]:=concat(ans[s+2], ' ');
for x:=s+3 to s+s+2 do
begin
for y:=1 to s+1 do
ans[x]:=concat(ans[x], ' ');
ans[x]:=concat(ans[x], '|');
end;
ans[s+s+3]:=concat(ans[s+s+3], ' ');
for x:=1 to s do
ans[s+s+3]:=concat(ans[s+s+3], '-');
ans[s+s+3]:=concat(ans[s+s+3], ' ');
end;
procedure zero(s:integer);
var
x,y:integer;
begin
ans[1]:=concat(ans[1], ' ');
for x:=1 to s do
ans[1]:=concat(ans[1], '-');
ans[1]:=concat(ans[1], ' ');
for x:=2 to s+1 do
begin
ans[x]:=concat(ans[x], '|');
for y:=1 to s do
ans[x]:=concat(ans[x], ' ');
ans[x]:=concat(ans[x], '|');
end;
for x:=1 to s+2 do
ans[s+2]:=concat(ans[s+2], ' ');
for x:=s+3 to s+2+s do
begin
ans[x]:=concat(ans[x], '|');
for y:=1 to s do
ans[x]:=concat(ans[x], ' ');
ans[x]:=concat(ans[x], '|');
end;
ans[s+s+3]:=concat(ans[s+s+3], ' ');
for x:=1 to s do
ans[s+s+3]:=concat(ans[s+s+3], '-');
ans[s+s+3]:=concat(ans[s+s+3], ' ');
end;
begin
a:=1;
p:=1;
inp:='2';
repeat
readln(p, inp);
delete(inp, 1,1);
sto[a]:=inp;
pe[a]:=p;
a:=a+1;
until (p=0) and (inp='0');
for n:=1 to a-2 do
begin
for i:=1 to 2*pe[n]+3 do
ans[i]:='';
for i:=1 to length(sto[n]) do
begin
if sto[n][i]='1' then one(pe[n]);
if sto[n][i]='2' then two(pe[n]);
if sto[n][i]='3' then three(pe[n]);
if sto[n][i]='4' then four(pe[n]);
if sto[n][i]='5' then five(pe[n]);
if sto[n][i]='6' then six(pe[n]);
if sto[n][i]='7' then seven(pe[n]);
if sto[n][i]='8' then eight(pe[n]);
if sto[n][i]='9' then nine(pe[n]);
if sto[n][i]='0' then zero(pe[n]);
for j:=1 to 2*pe[n]+3 do
if i<>length(sto[n]) then ans[j]:=concat(ans[j], ' ');
end;
for i:=1 to 2*pe[n]+3 do
begin
writeln(ans[i]);
end;
writeln;
end;
readln
end.
Code: Select all
#include<iostream>
#include <iomanip>
#include <string>
using namespace std;
int main()
{
int s;
string str_n;
int ptr_n;
cin>>s>>str_n;
while(s)
{
ptr_n=0;
int i;
for(i=0;i<2*s+3;i++)
{
while(str_n[ptr_n])
{
if(ptr_n)
cout<<" ";
if(i==0)
{
switch(str_n[ptr_n]) //first line
{
case '1':
case '4':
cout<<setw(s+2)<<" ";
break;
case '2':
case '3':
case '5':
case '6':
case '7':
case '8':
case '9':
case '0':
cout<<" "<<setfill('-')<<setw(s+1)<<" "<<setfill(' ');
break;
}
}
else if(i<s+1) //upper half
{
switch(str_n[ptr_n])
{
case '1':
case '2':
case '3':
case '7':
cout<<setw(s+2)<<"|";
break;
case '4':
case '8':
case '9':
case '0':
cout<<"|"<<setw(s+1)<<"|";
break;
case '5':
case '6':
cout<<"|"<<setw(s+1)<<" ";
break;
}
}
else if(i==s+1) //middle line
{
switch(str_n[ptr_n])
{
case '1':
case '7':
case '0':
cout<<setw(s+2)<<" ";
break;
case '2':
case '3':
case '4':
case '5':
case '6':
case '8':
case '9':
cout<<" "<<setfill('-')<<setw(s+1)<<" "<<setfill(' ');
break;
}
}
else if(i<2*s+2) //lower half
{
switch(str_n[ptr_n])
{
case '1':
case '3':
case '4':
case '5':
case '7':
case '9':
cout<<setw(s+2)<<"|";
break;
case '2':
cout<<"|"<<setw(s+1)<<" ";
break;
case '6':
case '8':
case '0':
cout<<"|"<<setw(s+1)<<"|";
break;
}
}
else //if(i==2*s+2) //last line
{
switch(str_n[ptr_n])
{
case '1':
case '4':
case '7':
cout<<setw(s+2)<<" ";
break;
case '2':
case '3':
case '5':
case '6':
case '8':
case '9':
case '0':
cout<<" "<<setfill('-')<<setw(s+1)<<" "<<setfill(' ');
break;
}
}
ptr_n++;
}
cout<<endl;
ptr_n=0;
}
cin>>s>>str_n;
if(s)
cout<<endl;
}
return 0;
}
Code: Select all
import java.io.*;
class Main
{
String[] One, Two, Three, Four, Five, Six, Seven, Eight, Nine, Zero;
String Begin(String Input, int Dimension)
{
Input = Input.substring(Input.indexOf(' ')+1, Input.length());
if (Input.indexOf('1') != -1)
{
One = new String[5];
One[0] = " ";
One[1] = " |";
One[2] = " ";
One[3] = " |";
One[4] = " ";
One = Stretch(One, Dimension);
}
if (Input.indexOf('2') != -1)
{
Two = new String[5];
Two[0] = " - ";
Two[1] = " |";
Two[2] = " - ";
Two[3] = "| ";
Two[4] = " - ";
Two = Stretch(Two, Dimension);
}
if (Input.indexOf('3') != -1)
{
Three = new String[5];
Three[0] = " - ";
Three[1] = " |";
Three[2] = " - ";
Three[3] = " |";
Three[4] = " - ";
Three = Stretch(Three, Dimension);
}
if (Input.indexOf('4') != -1)
{
Four = new String[5];
Four[0] = " ";
Four[1] = "| |";
Four[2] = " - ";
Four[3] = " |";
Four[4] = " ";
Four = Stretch(Four, Dimension);
}
if (Input.indexOf('5') != -1)
{
Five = new String[5];
Five[0] = " - ";
Five[1] = "| ";
Five[2] = " - ";
Five[3] = " |";
Five[4] = " - ";
Five = Stretch(Five, Dimension);
}
if (Input.indexOf('6') != -1)
{
Six = new String[5];
Six[0] = " - ";
Six[1] = "| ";
Six[2] = " - ";
Six[3] = "| |";
Six[4] = " - ";
Six = Stretch(Six, Dimension);
}
if (Input.indexOf('7') != -1)
{
Seven = new String[5];
Seven[0] = " - ";
Seven[1] = " |";
Seven[2] = " ";
Seven[3] = " |";
Seven[4] = " ";
Seven = Stretch(Seven, Dimension);
}
if (Input.indexOf('8') != -1)
{
Eight = new String[5];
Eight[0] = " - ";
Eight[1] = "| |";
Eight[2] = " - ";
Eight[3] = "| |";
Eight[4] = " - ";
Eight = Stretch(Eight, Dimension);
}
if (Input.indexOf('9') != -1)
{
Nine = new String[5];
Nine[0] = " - ";
Nine[1] = "| |";
Nine[2] = " - ";
Nine[3] = " |";
Nine[4] = " - ";
Nine = Stretch(Nine, Dimension);
}
if (Input.indexOf('0') != -1)
{
Zero = new String[5];
Zero[0] = " - ";
Zero[1] = "| |";
Zero[2] = " ";
Zero[3] = "| |";
Zero[4] = " - ";
Zero = Stretch(Zero, Dimension);
}
String[] Answer = new String[2*Dimension+3];
for (int i = 0; i < Answer.length; i++)
Answer[i] = "";
for (int i = 0; i < Input.length(); i++)
{
switch (Input.charAt(i))
{
case '1':
for (int j = 0; j < Answer.length; j++)
Answer[j] += One[j] + " ";
break;
case '2':
for (int j = 0; j < Answer.length; j++)
Answer[j] += Two[j] + " ";
break;
case '3':
for (int j = 0; j < Answer.length; j++)
Answer[j] += Three[j] + " ";
break;
case '4':
for (int j = 0; j < Answer.length; j++)
Answer[j] += Four[j] + " ";
break;
case '5':
for (int j = 0; j < Answer.length; j++)
Answer[j] += Five[j] + " ";
break;
case '6':
for (int j = 0; j < Answer.length; j++)
Answer[j] += Six[j] + " ";
break;
case '7':
for (int j = 0; j < Answer.length; j++)
Answer[j] += Seven[j] + " ";
break;
case '8':
for (int j = 0; j < Answer.length; j++)
Answer[j] += Eight[j] + " ";
break;
case '9':
for (int j = 0; j < Answer.length; j++)
Answer[j] += Nine[j] + " ";
break;
case '0':
for (int j = 0; j < Answer.length; j++)
Answer[j] += Zero[j] + " ";
break;
}
}
return ToString(Answer);
}
void Begin()
{
String Answer = "";
String Input = ReadLine(255);
while (!Input.equals("0 0"))
{
int Dimension = Integer.parseInt(Input.substring(0, Input.indexOf(' ')));
if (Dimension != 0)
{
Answer += Begin(Input, Dimension);
}
Input = ReadLine(255);
}
System.out.println(Answer);
}
static void main(String[] args)
{
Main LCD = new Main();
LCD.Begin();
}
static String ReadLine (int maxLg) {
byte lin[] = new byte [maxLg];
int lg = 0, car = -1;
String line = "";
try {
while (lg < maxLg) {
car = System.in.read();
if ((car < 0) || (car == '\n')) break;
lin [lg++] += car;
}
}
catch (IOException e) { return (null); }
if ((car < 0) && (lg == 0)) return (null);
return (new String (lin, 0, lg));
}
String[] Stretch(String[] Input, int Dimension)
{
Dimension--;
//Widen
for (int i = 0; i < Input.length; i++)
{
for (int j = 0; j < Dimension; j++)
{
Input[i] = Input[i].substring(0,2) + Input[i].substring(1,Input[i].length());
}
}
//Heighten
for (int i = 0; i < Dimension; i++)
{
String[] NewInput = new String[Input.length+2];
NewInput[0] = Input[0];
NewInput[1] = Input[1];
for (int j = 2; j < NewInput.length-2; j++)
NewInput[j] = Input[j-1];
NewInput[NewInput.length-2] = Input[Input.length-2];
NewInput[NewInput.length-1] = Input[Input.length-1];
Input = NewInput;
}
return Input;
}
void Output(String[] Input)
{
for (int i = 0; i < Input.length; i++)
{
System.out.println(Input[i].substring(0, Input[i].length()-1));
}
System.out.println();
}
String ToString(String[] Input)
{
String Answer = "";
for (int i = 0; i < Input.length; i++)
{
Answer += Input[i].substring(0, Input[i].length()-1) + "\n";
}
return Answer + "\n";
}
}
Code: Select all
1 1092387456
2 1234567890
3 0987654321
4 83
5 009584731
6 2247
0 0
- - - - - - - -
| | | | | | | | | | | | | |
- - - - - - -
| | | | | | | | | | | | |
- - - - - - -
-- -- -- -- -- -- -- --
| | | | | | | | | | | | | |
| | | | | | | | | | | | | |
-- -- -- -- -- -- --
| | | | | | | | | | | | |
| | | | | | | | | | | | |
-- -- -- -- -- -- --
--- --- --- --- --- --- --- ---
| | | | | | | | | | | | | |
| | | | | | | | | | | | | |
| | | | | | | | | | | | | |
--- --- --- --- --- --- ---
| | | | | | | | | | | | |
| | | | | | | | | | | | |
| | | | | | | | | | | | |
--- --- --- --- --- --- ---
---- ----
| | |
| | |
| | |
| | |
---- ----
| | |
| | |
| | |
| | |
---- ----
----- ----- ----- ----- ----- ----- -----
| | | | | | | | | | | | | |
| | | | | | | | | | | | | |
| | | | | | | | | | | | | |
| | | | | | | | | | | | | |
| | | | | | | | | | | | | |
----- ----- ----- ----- -----
| | | | | | | | | | | |
| | | | | | | | | | | |
| | | | | | | | | | | |
| | | | | | | | | | | |
| | | | | | | | | | | |
----- ----- ----- ----- ----- -----
------ ------ ------
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
------ ------ ------
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
------ ------
Code: Select all
...................... .--------------------. .--------------------. ...................... ......................
.....................| .....................| .....................| .....................| |....................|
.....................| .....................| .....................| .....................| |....................|
.....................| .....................| .....................| .....................| |....................|
.....................| .....................| .....................| .....................| |....................|
.....................| .....................| .....................| .....................| |....................|
.....................| .....................| .....................| .....................| |....................|
.....................| .....................| .....................| .....................| |....................|
.....................| .....................| .....................| .....................| |....................|
.....................| .....................| .....................| .....................| |....................|
.....................| .....................| .....................| .....................| |....................|
.....................| .....................| .....................| .....................| |....................|
.....................| .....................| .....................| .....................| |....................|
.....................| .....................| .....................| .....................| |....................|
.....................| .....................| .....................| .....................| |....................|
.....................| .....................| .....................| .....................| |....................|
.....................| .....................| .....................| .....................| |....................|
.....................| .....................| .....................| .....................| |....................|
.....................| .....................| .....................| .....................| |....................|
.....................| .....................| .....................| .....................| |....................|
.....................| .....................| .....................| .....................| |....................|
...................... .--------------------. .--------------------. ...................... .--------------------.
.....................| |..................... .....................| .....................| .....................|
.....................| |..................... .....................| .....................| .....................|
.....................| |..................... .....................| .....................| .....................|
.....................| |..................... .....................| .....................| .....................|
.....................| |..................... .....................| .....................| .....................|
.....................| |..................... .....................| .....................| .....................|
.....................| |..................... .....................| .....................| .....................|
.....................| |..................... .....................| .....................| .....................|
.....................| |..................... .....................| .....................| .....................|
.....................| |..................... .....................| .....................| .....................|
.....................| |..................... .....................| .....................| .....................|
.....................| |..................... .....................| .....................| .....................|
.....................| |..................... .....................| .....................| .....................|
.....................| |..................... .....................| .....................| .....................|
.....................| |..................... .....................| .....................| .....................|
.....................| |..................... .....................| .....................| .....................|
.....................| |..................... .....................| .....................| .....................|
.....................| |..................... .....................| .....................| .....................|
.....................| |..................... .....................| .....................| .....................|
.....................| |..................... .....................| .....................| .....................|
...................... .--------------------. .--------------------. ...................... ......................
.................................................... .--------------------------------------------------. .................................................... .--------------------------------------------------. .--------------------------------------------------. .--------------------------------------------------. .--------------------------------------------------.
...................................................| ...................................................| |..................................................| |..................................................| |................................................... |..................................................| |..................................................|
...................................................| ...................................................| |..................................................| |..................................................| |................................................... |..................................................| |..................................................|
...................................................| ...................................................| |..................................................| |..................................................| |................................................... |..................................................| |..................................................|
...................................................| ...................................................| |..................................................| |..................................................| |................................................... |..................................................| |..................................................|
...................................................| ...................................................| |..................................................| |..................................................| |................................................... |..................................................| |..................................................|
...................................................| ...................................................| |..................................................| |..................................................| |................................................... |..................................................| |..................................................|
...................................................| ...................................................| |..................................................| |..................................................| |................................................... |..................................................| |..................................................|
...................................................| ...................................................| |..................................................| |..................................................| |................................................... |..................................................| |..................................................|
...................................................| ...................................................| |..................................................| |..................................................| |................................................... |..................................................| |..................................................|
...................................................| ...................................................| |..................................................| |..................................................| |................................................... |..................................................| |..................................................|
...................................................| ...................................................| |..................................................| |..................................................| |................................................... |..................................................| |..................................................|
...................................................| ...................................................| |..................................................| |..................................................| |................................................... |..................................................| |..................................................|
...................................................| ...................................................| |..................................................| |..................................................| |................................................... |..................................................| |..................................................|
...................................................| ...................................................| |..................................................| |..................................................| |................................................... |..................................................| |..................................................|
...................................................| ...................................................| |..................................................| |..................................................| |................................................... |..................................................| |..................................................|
...................................................| ...................................................| |..................................................| |..................................................| |................................................... |..................................................| |..................................................|
...................................................| ...................................................| |..................................................| |..................................................| |................................................... |..................................................| |..................................................|
...................................................| ...................................................| |..................................................| |..................................................| |................................................... |..................................................| |..................................................|
...................................................| ...................................................| |..................................................| |..................................................| |................................................... |..................................................| |..................................................|
...................................................| ...................................................| |..................................................| |..................................................| |................................................... |..................................................| |..................................................|
...................................................| ...................................................| |..................................................| |..................................................| |................................................... |..................................................| |..................................................|
...................................................| ...................................................| |..................................................| |..................................................| |................................................... |..................................................| |..................................................|
...................................................| ...................................................| |..................................................| |..................................................| |................................................... |..................................................| |..................................................|
...................................................| ...................................................| |..................................................| |..................................................| |................................................... |..................................................| |..................................................|
...................................................| ...................................................| |..................................................| |..................................................| |................................................... |..................................................| |..................................................|
...................................................| ...................................................| |..................................................| |..................................................| |................................................... |..................................................| |..................................................|
...................................................| ...................................................| |..................................................| |..................................................| |................................................... |..................................................| |..................................................|
...................................................| ...................................................| |..................................................| |..................................................| |................................................... |..................................................| |..................................................|
...................................................| ...................................................| |..................................................| |..................................................| |................................................... |..................................................| |..................................................|
...................................................| ...................................................| |..................................................| |..................................................| |................................................... |..................................................| |..................................................|
...................................................| ...................................................| |..................................................| |..................................................| |................................................... |..................................................| |..................................................|
...................................................| ...................................................| |..................................................| |..................................................| |................................................... |..................................................| |..................................................|
...................................................| ...................................................| |..................................................| |..................................................| |................................................... |..................................................| |..................................................|
...................................................| ...................................................| |..................................................| |..................................................| |................................................... |..................................................| |..................................................|
...................................................| ...................................................| |..................................................| |..................................................| |................................................... |..................................................| |..................................................|
...................................................| ...................................................| |..................................................| |..................................................| |................................................... |..................................................| |..................................................|
...................................................| ...................................................| |..................................................| |..................................................| |................................................... |..................................................| |..................................................|
...................................................| ...................................................| |..................................................| |..................................................| |................................................... |..................................................| |..................................................|
...................................................| ...................................................| |..................................................| |..................................................| |................................................... |..................................................| |..................................................|
...................................................| ...................................................| |..................................................| |..................................................| |................................................... |..................................................| |..................................................|
...................................................| ...................................................| |..................................................| |..................................................| |................................................... |..................................................| |..................................................|
...................................................| ...................................................| |..................................................| |..................................................| |................................................... |..................................................| |..................................................|
...................................................| ...................................................| |..................................................| |..................................................| |................................................... |..................................................| |..................................................|
...................................................| ...................................................| |..................................................| |..................................................| |................................................... |..................................................| |..................................................|
...................................................| ...................................................| |..................................................| |..................................................| |................................................... |..................................................| |..................................................|
...................................................| ...................................................| |..................................................| |..................................................| |................................................... |..................................................| |..................................................|
...................................................| ...................................................| |..................................................| |..................................................| |................................................... |..................................................| |..................................................|
...................................................| ...................................................| |..................................................| |..................................................| |................................................... |..................................................| |..................................................|
...................................................| ...................................................| |..................................................| |..................................................| |................................................... |..................................................| |..................................................|
...................................................| ...................................................| |..................................................| |..................................................| |................................................... |..................................................| |..................................................|
.................................................... .--------------------------------------------------. .--------------------------------------------------. .--------------------------------------------------. .--------------------------------------------------. .--------------------------------------------------. ....................................................
...................................................| ...................................................| ...................................................| ...................................................| ...................................................| ...................................................| |..................................................|
...................................................| ...................................................| ...................................................| ...................................................| ...................................................| ...................................................| |..................................................|
...................................................| ...................................................| ...................................................| ...................................................| ...................................................| ...................................................| |..................................................|
...................................................| ...................................................| ...................................................| ...................................................| ...................................................| ...................................................| |..................................................|
...................................................| ...................................................| ...................................................| ...................................................| ...................................................| ...................................................| |..................................................|
...................................................| ...................................................| ...................................................| ...................................................| ...................................................| ...................................................| |..................................................|
...................................................| ...................................................| ...................................................| ...................................................| ...................................................| ...................................................| |..................................................|
...................................................| ...................................................| ...................................................| ...................................................| ...................................................| ...................................................| |..................................................|
...................................................| ...................................................| ...................................................| ...................................................| ...................................................| ...................................................| |..................................................|
...................................................| ...................................................| ...................................................| ...................................................| ...................................................| ...................................................| |..................................................|
...................................................| ...................................................| ...................................................| ...................................................| ...................................................| ...................................................| |..................................................|
...................................................| ...................................................| ...................................................| ...................................................| ...................................................| ...................................................| |..................................................|
...................................................| ...................................................| ...................................................| ...................................................| ...................................................| ...................................................| |..................................................|
...................................................| ...................................................| ...................................................| ...................................................| ...................................................| ...................................................| |..................................................|
...................................................| ...................................................| ...................................................| ...................................................| ...................................................| ...................................................| |..................................................|
...................................................| ...................................................| ...................................................| ...................................................| ...................................................| ...................................................| |..................................................|
...................................................| ...................................................| ...................................................| ...................................................| ...................................................| ...................................................| |..................................................|
...................................................| ...................................................| ...................................................| ...................................................| ...................................................| ...................................................| |..................................................|
...................................................| ...................................................| ...................................................| ...................................................| ...................................................| ...................................................| |..................................................|
...................................................| ...................................................| ...................................................| ...................................................| ...................................................| ...................................................| |..................................................|
...................................................| ...................................................| ...................................................| ...................................................| ...................................................| ...................................................| |..................................................|
...................................................| ...................................................| ...................................................| ...................................................| ...................................................| ...................................................| |..................................................|
...................................................| ...................................................| ...................................................| ...................................................| ...................................................| ...................................................| |..................................................|
...................................................| ...................................................| ...................................................| ...................................................| ...................................................| ...................................................| |..................................................|
...................................................| ...................................................| ...................................................| ...................................................| ...................................................| ...................................................| |..................................................|
...................................................| ...................................................| ...................................................| ...................................................| ...................................................| ...................................................| |..................................................|
...................................................| ...................................................| ...................................................| ...................................................| ...................................................| ...................................................| |..................................................|
...................................................| ...................................................| ...................................................| ...................................................| ...................................................| ...................................................| |..................................................|
...................................................| ...................................................| ...................................................| ...................................................| ...................................................| ...................................................| |..................................................|
...................................................| ...................................................| ...................................................| ...................................................| ...................................................| ...................................................| |..................................................|
...................................................| ...................................................| ...................................................| ...................................................| ...................................................| ...................................................| |..................................................|
...................................................| ...................................................| ...................................................| ...................................................| ...................................................| ...................................................| |..................................................|
...................................................| ...................................................| ...................................................| ...................................................| ...................................................| ...................................................| |..................................................|
...................................................| ...................................................| ...................................................| ...................................................| ...................................................| ...................................................| |..................................................|
...................................................| ...................................................| ...................................................| ...................................................| ...................................................| ...................................................| |..................................................|
...................................................| ...................................................| ...................................................| ...................................................| ...................................................| ...................................................| |..................................................|
...................................................| ...................................................| ...................................................| ...................................................| ...................................................| ...................................................| |..................................................|
...................................................| ...................................................| ...................................................| ...................................................| ...................................................| ...................................................| |..................................................|
...................................................| ...................................................| ...................................................| ...................................................| ...................................................| ...................................................| |..................................................|
...................................................| ...................................................| ...................................................| ...................................................| ...................................................| ...................................................| |..................................................|
...................................................| ...................................................| ...................................................| ...................................................| ...................................................| ...................................................| |..................................................|
...................................................| ...................................................| ...................................................| ...................................................| ...................................................| ...................................................| |..................................................|
...................................................| ...................................................| ...................................................| ...................................................| ...................................................| ...................................................| |..................................................|
...................................................| ...................................................| ...................................................| ...................................................| ...................................................| ...................................................| |..................................................|
...................................................| ...................................................| ...................................................| ...................................................| ...................................................| ...................................................| |..................................................|
...................................................| ...................................................| ...................................................| ...................................................| ...................................................| ...................................................| |..................................................|
...................................................| ...................................................| ...................................................| ...................................................| ...................................................| ...................................................| |..................................................|
...................................................| ...................................................| ...................................................| ...................................................| ...................................................| ...................................................| |..................................................|
...................................................| ...................................................| ...................................................| ...................................................| ...................................................| ...................................................| |..................................................|
...................................................| ...................................................| ...................................................| ...................................................| ...................................................| ...................................................| |..................................................|
.................................................... .--------------------------------------------------. .................................................... .--------------------------------------------------. .--------------------------------------------------. .--------------------------------------------------. .--------------------------------------------------.
Code: Select all
#include <stdio.h>
void draw(int mode, int size){
int i = 1;
for(i = 1; i<= size ; i++){
if(mode == 1)putchar('-');
else if(mode == 2) putchar('|');
else putchar(' ');
}
}
int main(){
int size, number, i, j, k, digit[8] = {0}, length, time = 0;
while(scanf("%d %d", &size, &number) == 2 && !(size == 0 && number == 0)) {
length = 0;
/*if(time != 0) putchar('\n');
time = 1; */
for(i = 0 ; number > 0 ; i++ ){
digit[i] = number % 10;
number /= 10 ;
length++;
}
if(number == 0) {
length = 1;
digit[0] = 0;
}
/**********TOP******/
for(i = length-1 ; i >= 0 ; i--){
switch(digit[i]){
case 1:
case 4:
{
putchar(' ');
draw(3,size);
putchar(' ');
break;
}
default:{
putchar(' ');
draw(1,size);
putchar(' ');
break;
}
}
if(i != 0)putchar(' ');
if(i == 0) putchar('\n');
}
/********UP********/
for(j = 1 ; j <= size ; j++){
for(i = length-1 ; i >= 0 ; i--){
switch(digit[i]){
case 1:
case 2:
case 3:
case 7:
{
putchar(' ');
draw(3,size);
putchar('|');
break;
}
case 4:
case 8:
case 9:
case 0:
{
putchar('|');
draw(3,size);
putchar('|');
break;
}
default:
{
putchar('|');
draw(3,size);
putchar(' ');
break;
}
}
if(i != 0)putchar(' ');
if(i == 0) putchar('\n');
}
}
/***********MIDDLE*****/
for(i = length-1 ; i >= 0 ; i--){
switch(digit[i]){
case 1:
case 0:
case 7:
{
putchar(' ');
draw(3,size);
putchar(' ');
break;
}
default:{
putchar(' ');
draw(1,size);
putchar(' ');
break;
}
}
if(i != 0)putchar(' ');
if(i == 0) putchar('\n');
}
/******DOWN**********/
for(j = 1 ; j <= size ; j++){
for(i = length-1 ; i >= 0 ; i--){
switch(digit[i]){
case 1:
case 4:
case 3:
case 5:
case 7:
case 9:
{
putchar(' ');
draw(3,size);
putchar('|');
break;
}
case 6:
case 8:
case 0:
{
putchar('|');
draw(3,size);
putchar('|');
break;
}
default:
{
putchar('|');
draw(3,size);
putchar(' ');
break;
}
}
if(i != 0)putchar(' ');
if(i == 0) putchar('\n');
}
}
/*****FLOOR***********/
for(i = length-1 ; i >= 0 ; i--){
switch(digit[i]){
case 1:
case 4:
case 7:
{
putchar(' ');
draw(3,size);
putchar(' ');
break;
}
default:{
putchar(' ');
draw(1,size);
putchar(' ');
break;
}
}
if(i != 0)putchar(' ');
if(i == 0) putchar('\n');
}
/****************/
putchar('\n');
}
return 0;
}
Code: Select all
#include <stdio.h>
void draw(int mode, int size){
int i = 1;
for(i = 1; i<= size ; i++){
if(mode == 1)putchar('-');
else if(mode == 2) putchar('|');
else putchar(' ');
}
}
int main(){
int size, number, i, j, k, digit[8] = {0}, length, time = 0;
while(scanf("%d %d", &size, &number) == 2 && !(size == 0 && number == 0)) {
length = 0;
/*if(time != 0) putchar('\n');
time = 1; */
if(number == 0) {
length = 1;
digit[0] = 0;
}
/***FIX****/
else{
for(i = 0 ; number > 0 ; i++ ){
digit[i] = number % 10;
number /= 10 ;
length++;
}
}
/**********TOP******/
for(i = length-1 ; i >= 0 ; i--){
switch(digit[i]){
case 1:
case 4:
{
putchar(' ');
draw(3,size);
putchar(' ');
break;
}
default:{
putchar(' ');
draw(1,size);
putchar(' ');
break;
}
}
if(i != 0)putchar(' ');
if(i == 0) putchar('\n');
}
/********UP********/
for(j = 1 ; j <= size ; j++){
for(i = length-1 ; i >= 0 ; i--){
switch(digit[i]){
case 1:
case 2:
case 3:
case 7:
{
putchar(' ');
draw(3,size);
putchar('|');
break;
}
case 4:
case 8:
case 9:
case 0:
{
putchar('|');
draw(3,size);
putchar('|');
break;
}
default:
{
putchar('|');
draw(3,size);
putchar(' ');
break;
}
}
if(i != 0)putchar(' ');
if(i == 0) putchar('\n');
}
}
/***********MIDDLE*****/
for(i = length-1 ; i >= 0 ; i--){
switch(digit[i]){
case 1:
case 0:
case 7:
{
putchar(' ');
draw(3,size);
putchar(' ');
break;
}
default:{
putchar(' ');
draw(1,size);
putchar(' ');
break;
}
}
if(i != 0)putchar(' ');
if(i == 0) putchar('\n');
}
/******DOWN**********/
for(j = 1 ; j <= size ; j++){
for(i = length-1 ; i >= 0 ; i--){
switch(digit[i]){
case 1:
case 4:
case 3:
case 5:
case 7:
case 9:
{
putchar(' ');
draw(3,size);
putchar('|');
break;
}
case 6:
case 8:
case 0:
{
putchar('|');
draw(3,size);
putchar('|');
break;
}
default:
{
putchar('|');
draw(3,size);
putchar(' ');
break;
}
}
if(i != 0)putchar(' ');
if(i == 0) putchar('\n');
}
}
/*****FLOOR***********/
for(i = length-1 ; i >= 0 ; i--){
switch(digit[i]){
case 1:
case 4:
case 7:
{
putchar(' ');
draw(3,size);
putchar(' ');
break;
}
default:{
putchar(' ');
draw(1,size);
putchar(' ');
break;
}
}
if(i != 0)putchar(' ');
if(i == 0) putchar('\n');
}
/****************/
putchar('\n');
}
return 0;
}
Code: Select all
#include<stdio.h>
#include<string.h>
#define TAM_NUM 9
void print0(int s, int *estado, int*cont){
switch(estado[0])
{
case 0:
{
printf(" ");
for(int i=0; i<s; i++)
printf("-");
printf(" ");
estado[0]=1;
break;
}
case 1:
case 3:
{
printf("|");
for(int i=0; i<s; i++)
printf(" ");
printf("|");
cont[0]++;
if(cont[0]==s){
cont[0]=0;
if(estado[0]==1)
estado[0]=2;
else estado[0] = 0;
}
break;
}
case 2:
{
for(int i=0; i<s+2; i++)
printf(" ");
estado[0]=3;
break;
}
}
}
void print1(int s, int *estado, int*cont){
switch(estado[1])
{
case 0:
{
for(int i=0; i<s+2; i++)
printf(" ");
estado[1]=1;
break;
}
case 1:
{
for(int i=0; i<s+1; i++)
printf(" ");
printf("|");
cont[1]++;
if(cont[1]==s){
cont[1]=0;
estado[1]=0;
}
break;
}
}
}
void print2(int s, int *estado, int*cont){
switch(estado[2])
{
case 0:
{
printf(" ");
for(int i=0; i<s; i++)
printf("-");
printf(" ");
estado[2]=1;
break;
}
case 1:
{
for(int i=0; i<s+1; i++)
printf(" ");
printf("|");
cont[2]++;
if(cont[2]==s){
cont[2]=0;
estado[2]=2;
}
break;
}
case 2:
{
printf(" ");
for(int i=0; i<s; i++)
printf("-");
printf(" ");
estado[2]=3;
break;
}
case 3:
{
printf("|");
for(int i=0; i<s+1; i++)
printf(" ");
cont[2]++;
if(cont[2]==s){
cont[2]=0;
estado[2]=0;
}
break;
}
}
}
void print3(int s, int *estado, int*cont){
switch(estado[3])
{
case 0:
{
printf(" ");
for(int i=0; i<s; i++)
printf("-");
printf(" ");
estado[3]=1;
break;
}
case 1:
{
for(int i=0; i<s+1; i++)
printf(" ");
printf("|");
cont[3]++;
if(cont[3]==s){
cont[3]=0;
estado[3]=0;
}
break;
}
}
}
void print4(int s, int *estado, int*cont){
switch(estado[4])
{
case 0:
{
for(int i=0; i<s+2; i++)
printf(" ");
estado[4]=1;
break;
}
case 1:
{
printf("|");
for(int i=0; i<s; i++)
printf(" ");
printf("|");
cont[4]++;
if(cont[4]==s){
cont[4]=0;
estado[4]=2;
}
break;
}
case 2:
{
printf(" ");
for(int i=0; i<s; i++)
printf("-");
printf(" ");
estado[4]=3;
break;
}
case 3:
{
for(int i=0; i<s+1; i++)
printf(" ");
printf("|");
cont[4]++;
if(cont[4]==s){
cont[4]=0;
estado[4]=0;
}
break;
}
}
}
void print5(int s, int *estado, int*cont){
switch(estado[5])
{
case 0:
{
printf(" ");
for(int i=0; i<s; i++)
printf("-");
printf(" ");
estado[5]=1;
break;
}
case 1:
{
printf("|");
for(int i=0; i<s+1; i++)
printf(" ");
cont[5]++;
if(cont[5]==s){
cont[5]=0;
estado[5]=2;
}
break;
}
case 2:
{
printf(" ");
for(int i=0; i<s; i++)
printf("-");
printf(" ");
estado[5]=3;
break;
}
case 3:
{
for(int i=0; i<s+1; i++)
printf(" ");
printf("|");
cont[5]++;
if(cont[5]==s){
cont[5]=0;
estado[5]=0;
}
break;
}
}
}
void print6(int s, int *estado, int*cont){
switch(estado[6])
{
case 0:
{
printf(" ");
for(int i=0; i<s; i++)
printf("-");
printf(" ");
estado[6]=1;
break;
}
case 1:
{
printf("|");
for(int i=0; i<s+1; i++)
printf(" ");
cont[6]++;
if(cont[6]==s){
cont[6]=0;
estado[6]=2;
}
break;
}
case 2:
{
printf(" ");
for(int i=0; i<s; i++)
printf("-");
printf(" ");
estado[6]=3;
break;
}
case 3:
{
printf("|");
for(int i=0; i<s; i++)
printf(" ");
printf("|");
cont[6]++;
if(cont[6]==s){
cont[6]=0;
estado[6]=0;
}
break;
}
}
}
void print7(int s, int *estado, int*cont){
switch(estado[7])
{
case 0:
{
printf(" ");
for(int i=0; i<s; i++)
printf("-");
printf(" ");
estado[7]=1;
break;
}
case 1:
{
for(int i=0; i<s+1; i++)
printf(" ");
printf("|");
cont[7]++;
if(cont[7]==s){
cont[7]=0;
estado[7]=2;
}
break;
}
case 2:
{
for(int i=0; i<s+2; i++)
printf(" ");
estado[7]=1;
break;
}
}
}
void print8(int s, int *estado, int*cont){
switch(estado[8])
{
case 0:
{
printf(" ");
for(int i=0; i<s; i++)
printf("-");
printf(" ");
estado[8]=1;
break;
}
case 1:
{
printf("|");
for(int i=0; i<s; i++)
printf(" ");
printf("|");
cont[8]++;
if(cont[8]==s){
cont[8]=0;
estado[8]=0;
}
break;
}
}
}
void print9(int s, int *estado, int*cont){
switch(estado[9])
{
case 0:
{
printf(" ");
for(int i=0; i<s; i++)
printf("-");
printf(" ");
estado[9]=1;
break;
}
case 1:
{
printf("|");
for(int i=0; i<s; i++)
printf(" ");
printf("|");
cont[9]++;
if(cont[9]==s){
cont[9]=0;
estado[9]=2;
}
break;
}
case 2:
{
printf(" ");
for(int i=0; i<s; i++)
printf("-");
printf(" ");
estado[9]=3;
break;
}
case 3:
{
for(int i=0; i<s+1; i++)
printf(" ");
printf("|");
cont[9]++;
if(cont[9]==s)
{
cont[9]=0;
estado[9]=0;
}
break;
}
}
}
int main()
{
int s;
char n[TAM_NUM];
bool v[TAM_NUM];
int estado[TAM_NUM], cont[TAM_NUM], tempEstado[TAM_NUM], tempCont[TAM_NUM];
scanf("%d", &s);
while( s!= 0)
{
for(int i=0; i<TAM_NUM; i++){
n[i]='\0';
v[i]=false;
estado[i]= cont[i] = 0;
}
getchar();
gets(n);
for(int i=0; i<TAM_NUM; i++) //marca os numeros que foram impressoas, resolve o probn
v[i] = false;
int indN = 0;
for(int i=0; i< 2*s+3; i++) //percorre as linhas
{
for(int j=0; j<strlen(n); j++) //percorre as colunas
{
int num = n[indN]-'0';
if(v[num]==false){
tempEstado[num] = estado[num];
tempCont[num] = cont[num];
v[num]=true;
}
else{
estado[num] = tempEstado[num];
cont[num] = tempCont[num];
}
switch(n[indN])
{
case '0': print0(s, estado, cont); break;
case '1': print1(s, estado, cont); break;
case '2': print2(s, estado, cont); break;
case '3': print3(s, estado, cont); break;
case '4': print4(s, estado, cont); break;
case '5': print5(s, estado, cont); break;
case '6': print6(s, estado, cont); break;
case '7': print7(s, estado, cont); break;
case '8': print8(s, estado, cont); break;
case '9': print9(s, estado, cont); break;
}
indN++;
if(indN==strlen(n)) printf("\n");
else printf(" ");
}
for(int i=0; i<TAM_NUM; i++) //marca os numeros que foram impressoas, resolve o probn
v[i] = false;
indN=0;
}
printf("\n");
scanf("%d", &s);
}
return 0;
}