Turn VERTICAL letters HORIZONTAL (for loop problem)

Hi everyone!

Well, this is what I have, I wrote the code using arrays to form the over-sized letters, but they display vertically when I want them to display horizontally.

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
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
//Program to write my name in oversized letters
#include<iostream>  /* header file for input and output */
#include<cmath>
using namespace std;
int main ()      /* allow operations from standard library */
{
    char W[7][10] = {"W       W",
                     "W       W",
                     "W       W",
                     "W   W   W",
                     "W  W W  W",
                     "W W   W W",
                     "WW     WW"};
    
    char I[7][10] = {"IIIIIIIII",
                     "    I    ",
                     "    I    ",
                     "    I    ",
                     "    I    ",
                     "    I    ",
                     "IIIIIIIII"};
                     
    char L[7][10] = {"L        ",
                     "L        ",
                     "L        ",
                     "L        ",
                     "L        ",
                     "L        ",
                     "LLLLLLLLL"};                 
                     
    char J[7][10] = {"JJJJJJJJJ",
                     "     J   ",
                     "     J   ",
                     "     J   ",
                     "     J   ",
                     "J    J   ",
                     " JJJJ    "};   
                     
    char O[7][10] = {" OOOOOOO ",
                     "O       O",
                     "O       O",
                     "O       O",
                     "O       O",
                     "O       O",
                     " OOOOOOO "};
                     
    char H[7][10] = {"H       H",
                     "H       H",
                     "H       H",
                     "HHHHHHHHH",
                     "H       H",
                     "H       H",
                     "H       H"}; 
                     
    char N[7][10] = {"NN      N",
                     "N N     N",
                     "N  N    N",
                     "N   N   N",
                     "N    N  N",
                     "N     N N",
                     "N      NN"};    
           
    char S[7][10] = {" SSSSSSS ",
                     "S       S",
                     "S        ",
                     " SSSSSSS ",
                     "        S",
                     "S       S",
                     " SSSSSSS "};
                     
                                                                            
    for(int r=0; r<7; r++)
            {
                 for (int c=0; c<10; c++)
                     {
                          cout<<W[r][c];
                          }
                 cout<<endl;
                 }
                 cout<<endl;
                 
    for(int r=0; r<7; r++)
            {
                 for (int c=0; c<10; c++)
                     {
                          cout<<I[r][c];
                          }
                 cout<<endl;
                 }
                 cout<<endl;
                 
    for(int r=0; r<7; r++)
            {
                 for (int c=0; c<10; c++)
                     {
                          cout<<L[r][c];
                          }
                 cout<<endl;
                 }
                 cout<<endl;
                 
    for(int r=0; r<7; r++)
            {
                 for (int c=0; c<10; c++)
                     {
                          cout<<L[r][c];
                          }
                 cout<<endl;
                 }
                 cout<<endl;
                 
    for(int r=0; r<7; r++)
            {
                 for (int c=0; c<10; c++)
                     {
                          cout<<J[r][c];
                          }
                 cout<<endl;
                 }
                 cout<<endl;
                 
    for(int r=0; r<7; r++)
            {
                 for (int c=0; c<10; c++)
                     {
                          cout<<O[r][c];
                          }
                 cout<<endl;
                 }
                 cout<<endl;
                 
    for(int r=0; r<7; r++)
            {
                 for (int c=0; c<10; c++)
                     {
                          cout<<H[r][c];
                          }
                 cout<<endl;
                 }
                 cout<<endl;
                 
    for(int r=0; r<7; r++)
            {
                 for (int c=0; c<10; c++)
                     {
                          cout<<N[r][c];
                          }
                 cout<<endl;
                 }
                 cout<<endl;
                 
    for(int r=0; r<7; r++)
            {
                 for (int c=0; c<10; c++)
                     {
                          cout<<S[r][c];
                          }
                 cout<<endl;
                 }     
                 cout<<endl;
                         
    for(int r=0; r<7; r++)
            {
                 for (int c=0; c<10; c++)
                     {
                          cout<<O[r][c];
                          }
                 cout<<endl;
                 }
                 cout<<endl;           
    for(int r=0; r<7; r++)
            {
                 for (int c=0; c<10; c++)
                     {
                          cout<<N[r][c];
                          }
                 cout<<endl;
                 }          
                 cout<<endl;   
    system ("pause"); //leaves window up
    return 0; //End of main function
}




When compiled, this gives all the letters as I mean them to look, but descending vertically. For the assignment, I need them to display horizontally.
Any help greatly appreciated, thanks!
Last edited on
Well, with console output, you're pretty much stuck doing one line at a time unless you pull some terminal trick with some OS-specific libraries. So think about the problem as each mulit-line letter consisting of several rows of text.

You want to print the top row of W, then the top row of I, then the top row of L, and so forth until you print the top row of N.

After you print the top row of N, you then want to start printing the next row of each multi-line letter. I suggest outputting an 'endl' so you start on a new line.

The good news? You can accomplish this with a single loop.
Last edited on
Replace all of you for loops with the following.

1
2
for(int r=0; r<7; r++)
  cout << W[r] << " " << I[r] << " " << L[r] << " " << L[r] << " " << J[r] << " " << O[r] << " " << H[r] << " " << N[r] << " " << S[r] << " " << O[r] << " " << N[r] << endl;
Thanks everyone. The necessary steps were:

exchange my 'for' loops for one overarching 'for' loop
AND
change the width of my output window (properties>layout>width)



If you don't want to fiddle with your output console, you could put it in a file and check the output in your favorite text editor.

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
#include <iostream>
#include <fstream>

int main()
{
    char W[7][10] = {"W       W",
                     "W       W",
                     "W       W",
                     "W   W   W",
                     "W  W W  W",
                     "W W   W W",
                     "WW     WW"};
    
    char I[7][10] = {"IIIIIIIII",
                     "    I    ",
                     "    I    ",
                     "    I    ",
                     "    I    ",
                     "    I    ",
                     "IIIIIIIII"};
                     
    char L[7][10] = {"L        ",
                     "L        ",
                     "L        ",
                     "L        ",
                     "L        ",
                     "L        ",
                     "LLLLLLLLL"};                 
                     
    char J[7][10] = {"JJJJJJJJJ",
                     "     J   ",
                     "     J   ",
                     "     J   ",
                     "     J   ",
                     "J    J   ",
                     " JJJJ    "};   
                     
    char O[7][10] = {" OOOOOOO ",
                     "O       O",
                     "O       O",
                     "O       O",
                     "O       O",
                     "O       O",
                     " OOOOOOO "};
                     
    char H[7][10] = {"H       H",
                     "H       H",
                     "H       H",
                     "HHHHHHHHH",
                     "H       H",
                     "H       H",
                     "H       H"}; 
                     
    char N[7][10] = {"NN      N",
                     "N N     N",
                     "N  N    N",
                     "N   N   N",
                     "N    N  N",
                     "N     N N",
                     "N      NN"};    
           
    char S[7][10] = {" SSSSSSS ",
                     "S       S",
                     "S        ",
                     " SSSSSSS ",
                     "        S",
                     "S       S",
                     " SSSSSSS "};

    std::ofstream myFile;
    myFile.open("output.txt");

    for(int i = 0; i < 7; i++)
    {
        myFile << W[i] << " ";
        myFile << I[i] << " ";
        myFile << L[i] << " ";
        myFile << L[i] << " ";
        myFile << J[i] << " ";
        myFile << O[i] << " ";
        myFile << H[i] << " ";
        myFile << N[i] << " ";
        myFile << S[i] << " ";
        myFile << O[i] << " ";
        myFile << N[i] << " ";

        myFile << std::endl;
    }
    myfile.close();
    return 0;
}


EDIT: forgot myfile.close() Big mistake!
Last edited on
Topic archived. No new replies allowed.