Printing ASCII-like chars and there is a bug I can't find in char's drawing

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP

Printing ASCII-like chars and there is a bug I can't find in char's drawing



The following code prints the big letter with shadows (with : chars). If a user provides only 1 letter as input, everything is fine. But if the user inputs more than 1 letter, something goes wrong. The letters look strange (shadow is incorrect too).


:


#include <iostream>
using namespace std;

// A~Z and some symbols
int main()

int A[6][6]=0,1,1,1,1,0,
1,1,1,1,1,1,
1,1,0,0,1,1,
1,1,0,0,1,1,
1,1,1,1,1,1,
1,1,0,0,1,1;

int B[6][6]=1,1,1,1,1,0,
1,1,1,1,1,1,
1,1,0,0,1,1,
1,1,1,1,1,1,
1,1,0,0,1,1,
1,1,1,1,1,0;

//int C[6][6]...........

int k;

string input;
cin >> input; // a user inputs the symbols

k = input.length()*8; // total length for define sum
cout << k << endl; // debug output
int sum[k][8]; // the final array prepare to print

// make all the space 0. Didn't sure if it's necessary.
for (int i = 0; i < 8; i++)

for (int j = 0; j < k; j++)

sum[i][j] = 0;



// start combining the symbols
for (int h = 0; h < k/8; h++) // run input.length() time.

for (int i = 0; i < 6; i++) // 6 for vertical

for (int j = 0; j < 6; j++) // 6 for horizontal

//string word = input.substr(h,1);
//I haven't program the other letters
//so I print A temporary.
sum[i+1][(h*8)+j+1] = A[i][j];
if(sum[i+1][h*8+j+1])cout << i+1 << h*8+j+1 << " ";

cout << endl;

cout << endl;


// casting the shadow
for (int i = 0; i < 8; i++)

for (int j = 0; j < k; j++)

if (sum[i][j] == 1 && sum[i+1][j-1] == 0)

sum[i+1][j-1] = 2;




// top border
for(int i = 0; i < k; i++) cout << "==";
cout << endl;

// start printing the sum.
for (int i = 0; i < 8; i++) // 8 for vertical

for (int j = 0; j < k; j++) // k for horizontal

switch (sum[i][j])

case 0:
cout << " "; // nothing there
break;
case 1:
cout << ""; // part of a letter
break;
case 2:
cout << "::"; // the shadow
break;


cout << "n"; // for next line.


// bottom border
for (int i = 0; i < k * 2; i++) cout << "=";
cout << endl;



I enter 2 letters and it outputs


===============================

::
::
::::::
:::::: :: ::
:: :: ::
:: ::::::
:::::: :::: ::::
================================



I can't find what's wrong.





You can try using a debugger.
– Fei Xiang
21 mins ago





You need to be clearer when posting. The title explains very little of the problem you want to solve. A way I like to think when posting a question is: how other people with the same problem can benefit from this question? Take a look here and refactor your question. Hope it helped! :)
– LTKills
12 mins ago









By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Comments

Popular posts from this blog

Executable numpy error

Trying to Print Gridster Items to PDF without overlapping contents

Hystrix command on request collapser fallback