cross text

hello i am tring to make something that takes a string (name of person) and
crosses them like this

b b
o
b b

this would cross the letter bob and they share the middle letter and if it was a even number they would share the next closest letter like this
b b
i i
l
l l
here is the name bill which has a even number of letters.
so i know i would have to use dynamic memory for it to have enough space for the name that wouldnt be to hard but the real problem is i would need a function
that would cross the two of the strings.

i think i would use character sequences so i could pace each letter but if you any thing better or a function that would print them accross please let me know.
What is crossing ? Do you just want to print the letters in a column, duplicating every except the middle one ?
pseudocode, since I don't know if you want to use std::string or char[].
middle = (name_length+1)/2 //+1 for rounding up
for i = 0 to name_length do
   print name[i]
   if i != middle then print name[i]
   print '\n'
end for
TC means like:
b b
 o
b b

or
b   b
 i i
  l
 l l

I would think.
what's TC ?

@OP, if that's the case, use the same logic as when printing a triangle. It might be best to consider printing top, middle and bottom as three separate tasks. Notice how many spaces each gal needs and how that number changes.
Last edited on
Topic archived. No new replies allowed.