-
Notifications
You must be signed in to change notification settings - Fork 1
/
ABAKUS.cpp
executable file
·159 lines (122 loc) · 2.31 KB
/
ABAKUS.cpp
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
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <string>
#include <algorithm>
#define FOR(i,a,b) for(long long i = a ; i < b ; ++i )
#define PB push_back
#define VI vector<int>
#define L cout << "|"
#define STAR cout << "*"
#define SPACE cout << " "
#define ENDL cout << endl
using namespace std;
string getAbakus( ){
string result = "";
string temp;
vector< int > help;
getline( cin, temp );
help = vector< int >( temp.length() - 2 );
getline( cin, temp );
getline( cin, temp );
FOR( i, 1 , temp.length() - 1 ){
if( temp[ i ] == '*' )
help[ i - 1 ] = 0;
else
help[ i - 1 ] = 5;
}
getline( cin, temp );
getline( cin, temp );
FOR( i, 1, 11 ){
getline( cin, temp );
if( i <= 4 )
FOR( k, 1, temp.length() - 1 )
if( temp[ k ] == '*' ) help[ k-1 ]++;
}
int cond = false;
for( int i = 0 ; i < help.size() ; ++i ){
if( help[ i ] != 0 ) cond = true;
if( cond )
result += char( 48 + help[ i ] );
}
if( cond == false ) result = "0";
return result;
}
void createAbakus( string & s ){
string temp = "";
bool cond = false;
FOR( i, 0, s.length() ){
if( s[ i ] != '0' ) cond = true;
if( cond ) temp += s[ i ];
}
s = temp;
if( cond == false ) s = "0";
vector< int > arr;
for( auto i : s ){
arr.PB( int( i ) - 48 );
}
for( int i = 0 ; i < s.length()+2 ; ++i ){
cout << "-" ;
}
ENDL;
L;
FOR( i, 0, s.length() ) STAR;
L;
ENDL;
L;
FOR( i, 0, s.length() )
if( arr[ i ] <= 4 ) STAR;
else SPACE;
L;
ENDL;
L;
FOR( i, 0, s.length() )
if( arr[ i ] > 4 ) STAR;
else SPACE;
L;
ENDL;
L;
FOR( i, 0, s.length() ) cout << "-";
L;
ENDL;
FOR( i, 1, 10){
L;
FOR( j, 0, arr.size() ){
if( i <= 4 ) {
if( (i <= arr[ j ] and arr[ j ] <=4 ) or ( arr[ j ] > 4 and i <= arr[ j ] - 5 ))STAR;
else SPACE;
}
else{
if( (arr[ j ] > 4 and i >= arr[ j ] ) or ( arr[ j ] <=4 and i > 4 + arr[ j ] )) STAR;
else SPACE;
}
}
L;
ENDL;
}
for( int i = 0 ; i < s.length()+2 ; ++i ){
cout << "-" ;
}
ENDL;
}
int main(){
string s;
int x;
vector< int > arr;
while( getline( cin, s ) ){
if( cin.eof() ) break;
if( stoi( s ) ){
getline( cin, s );
createAbakus( s );
}
else{
s = getAbakus( );
cout << s << endl;
}
}
return 0 ;
}