1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139
|
#include <cstdio>
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <cstdarg>
#include <csetjmp>
std::map<bool,std::map<int,std::vector<std::pair<int,char> > > > magic_line;
#define one magic_line[1]
#define zero magic_line[0]
#define printf not_from_C_library
namespace
{
class
{
public: void operator++(int)
{
{
std::vector<std::pair<int,char> > &n = zero[0];
std::pair<int,char> arr [] = {
std::make_pair(2,' '),
std::make_pair(2,'-'),
std::make_pair(2,' '),
};
n = std::vector<std::pair<int,char> > ( arr, arr+sizeof(arr)/sizeof(arr[0]) );
}
{
std::vector<std::pair<int,char> > &n = zero[1];
std::pair<int,char> arr [] = {
std::make_pair(1,' '),
std::make_pair(1,'|'),
std::make_pair(2,' '),
std::make_pair(1,'|'),
std::make_pair(1,' '),
};
n = std::vector<std::pair<int,char> > ( arr, arr+sizeof(arr)/sizeof(arr[0]) );
}
{
std::vector<std::pair<int,char> > &
n = zero[2];
n = zero[1];
}
{
std::vector<std::pair<int,char> > &
n = zero[3];
n = zero[0];
}
{
std::vector<std::pair<int,char> > &n = one[0];
std::pair<int,char> arr [] = {
std::make_pair(2,' '),
std::make_pair(1,'/'),
std::make_pair(1,'|'),
std::make_pair(2,' ')
};
n = std::vector<std::pair<int,char> > ( arr, arr+sizeof(arr)/sizeof(arr[0]) );
}
{
std::vector<std::pair<int,char> > &n = one[1];
std::pair<int,char> arr [] = {
std::make_pair(1,' '),
std::make_pair(1,'/'),
std::make_pair(1,' '),
std::make_pair(1,'|'),
std::make_pair(2,' ')
};
n = std::vector<std::pair<int,char> > ( arr, arr+sizeof(arr)/sizeof(arr[0]) );
}
{
std::vector<std::pair<int,char> > &n = one[2];
std::pair<int,char> arr [] = {
std::make_pair(3,' '),
std::make_pair(1,'|'),
std::make_pair(2,' ')
};
n = std::vector<std::pair<int,char> > ( arr, arr+sizeof(arr)/sizeof(arr[0]) );
}
{
std::vector<std::pair<int,char> > &n = one[3];
std::pair<int,char> arr [] = {
std::make_pair(1,' '),
std::make_pair(4,'-'),
std::make_pair(1,' ')
};
n = std::vector<std::pair<int,char> > ( arr, arr+sizeof(arr)/sizeof(arr[0]) );
}
}
}c;
class _
{
public: _() { c++ ; }
}d;
}
void print_number ( const char *format, ... )
{
va_list vl;
va_start(vl,format);
bool va_bool = va_arg ( vl, int );
int va_int = va_arg ( vl, int );
va_end(vl);
std::vector<std::pair<int,char> > &va_vector = magic_line[va_bool][va_int];
jmp_buf back;
int i = 0;
setjmp(back);
std::cout << std::string ( va_vector[i].first, va_vector[i].second );
if ( ! ( i++ != va_vector.size() ) || ( longjmp(back,0), i++ != va_vector.size() ) );
}
int printf ( const char *format, ... )
{
print_number ( format, 1, 0 );
const char *back = format;
for ( int i = 0; i < 4; i++, format = back-1, std::cout << std::endl )
while ( *++format )
if ( ! ( *format - '0' ) )
print_number ( format, 0, i );
else if ( ! ( *format - '1' ) )
print_number ( format, 1, i );
else if ( ! ( *format - '\n' ) )
{
if ( i == 3 )
i = -1, *( back = format+1 ), std::cout << std::endl;
break;
}
return 0;
}
int main()
{
printf ( "1\n01\n101\n0101\n10101" );
}
|
/|
/ |
|
----
-- /|
| | / |
| | |
-- ----
/| -- /|
/ | | | / |
| | | |
---- -- ----
-- /| -- /|
| | / | | | / |
| | | | | |
-- ---- -- ----
/| -- /| -- /|
/ | | | / | | | / |
| | | | | | |
---- -- ---- -- ---- |