Skip to content

Instantly share code, notes, and snippets.

@naimurhasan
Created December 27, 2022 17:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save naimurhasan/4f09838064191def5e43a136c19b0599 to your computer and use it in GitHub Desktop.
Save naimurhasan/4f09838064191def5e43a136c19b0599 to your computer and use it in GitHub Desktop.
#include <bits/stdc++.h>
using namespace std;
#define RC 5
#define CC 2
void displayNum(int[RC][CC], int, bool);
/*
Sample Output
size 3
*/
int digits[10][RC][CC] = {
{{1},
{1, 1},
{0},
{1, 1},
{1}},
{{0},
{0, 1},
{0},
{0, 1},
{0}},
{{1},
{0, 1},
{1},
{1, 0},
{1}},
{{1},
{0, 1},
{1},
{0, 1},
{1}},
{{0},
{1, 1},
{1},
{0, 1},
{}},
{{1},
{1, 0},
{1},
{0, 1},
{1}},
{{1},
{1, 0},
{1},
{1, 1},
{1}},
{{1},
{1, 1},
{0},
{0, 1},
{0}},
{{1},
{1, 1},
{1},
{1, 1},
{1}},
{{1},
{1, 1},
{1},
{0, 1},
{1}}};
// create top dash
void dash(int nums[][RC][CC], int size, int len, int row)
{
// for each number
for(int i = 0; i < len; i++){
cout << " ";
for(int j = 0; j < size; j++){
if(nums[i][row][0] == 1){
cout<<"-";
}else{
cout<<" ";
}
}
cout << " ";
}
cout << " ";
cout << endl;
}
void column(int nums[][RC][CC], int size, int len, int row){
for(int k = 0; k<size; k++){
for(int i = 0; i < len; i++){
if(nums[i][row][0] == 1)
cout << "|";
else
cout << " ";
for(int j = 0; j < size; j++){
cout<<" ";
}
if(nums[i][row][1] == 1)
cout << "|";
else
cout << " ";
cout << " ";
}
cout << endl;
}
}
int main()
{
long long int size, line;
cin >> size >> line;
while(size || line){
string d = to_string(line);
int len = d.size();
int nums[len][RC][CC];
for(int ii = 0; ii < len; ii++){
int n = int(d[ii])-48;
for (int i = 0; i < RC; i++)
{
for (int j = 0; j < CC; j++)
{
nums[ii][i][j] = digits[n][i][j];
}
}
}
// display
dash(nums, size, len, 0);
column(nums, size, len, 1);
dash(nums, size, len, 2);
column(nums, size, len, 3);
dash(nums, size, len, 4);
cout << endl;
cin >> size >> line;
}
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment