Sunday, May 10, 2009

What is the c++ code runnable in dev c++ developmental tool, for this output????

What is the c++ code runnable in dev c++ developmental tool, for this output????








(it will be like this if the number of amount of string is an even number. and prints like a shape of a hour glass)





enter string: ccss


c c


c


s


s s





enter string: ccss


c c


c


s


s s





(it will be like this if the number of amount of string is an odd number)








enter string: table


t t t


a a


b


l l


e e e








(note: it should be 3 strings to be accepted as input(string) in this program)





Additional Details





1 week ago


What is the c++ code runnable in dev c++ developmental tool, for this output????


what is the c++ code runnable in dev c++ developmental too, for this output????


it will accept a string and creates a figure,, like in the following:





(it will be like this if the number of amount of string is an even number. and prints like a shape of a hour glass)





enter string: ccss


c c


c


s


s s

What is the c++ code runnable in dev c++ developmental tool, for this output????
do an if mod 2 on the string length to figure out if it is even or odd, if it is even generate two strings from the original by going from 0 to length/2 and length/2 to length.





For output cout from within 2 loops, one after the other, the first loop dealing with the first substring, the second loop dealing with the second substring.





The loop will simply start at the length of the substring and decrement to 0, each time printing length number of characters from the substring to the screen.





The second loop will do the same but in reverse, starting at 1 and stoping at length.





Don't understand what you ment for odd numbers but it will be similar to the above.


No comments:

Post a Comment