English Deutsch Français Italiano Español Português 繁體中文 Bahasa Indonesia Tiếng Việt ภาษาไทย
All categories

i have to write a program that will allow the user to enter two words tht share a common letter and instuct the computer to print them out in a cross at the common letter.
example:

P
ANT
L
S

2006-12-28 13:43:24 · 1 answers · asked by Anonymous in Computers & Internet Programming & Design

1 answers

Assume that 1st word entered will be printed verticle and second word horizontal.

Load letters of each word into an array (ayVert() & ayHorz() )

Using FOR/NEXT Loop start with first letter in the verticle array ayVert(0) and compare it to each letter in the horizontal array ayHorz(0) to ayHorz(what ever last letter index is)

if you find a match stop searching exit the for/next loop and then...

Determine how to print words...

Using your example words a match would be found between
ayVert(1) and ayHorz(0) the letters A

the index value of zero in ayHorz(0) means the first letter of the horizontal word. So you do not have to add any spaces before printing the Verticle letters

the index value of 1 in ayVert(1) means the second line you print is going to have the entire Horizontal word printed.

So to properly print you start printing the letters in the verticle word one letter per line adding spaces before each letter the number of which corresponds to the index value of the matching ayHorz() letter...

As each verticle letter is printed you do a carridge return line feed
and repeat printing (x) number of spaces and the verticle letter

you do this until you reach the line where you have to print the horizontal word. Here instead of printing the spaces and verticle letter you print the entire ayHorz() array horizontaly

next line you skip to the next verticle letter and continue until you finish printing the verticle array.

2006-12-28 18:09:34 · answer #1 · answered by MarkG 7 · 0 0

fedest.com, questions and answers