How could I get a program to generate something like this? It displays 1 and 2 the same increasing amount of times until it gets to six.
121122111222111122221111122222111111222222
I feel like this should be really easy but I can't quite place what I need to do. I would think a for-loop would work here but I might be wrong.
Thanks!
How about this silly method? It needs just one for loop!
@pastamaker: This is probably NOT how you are supposed to do it (for your assignment).
@firedraco: Sorry, but it looks like the cat's out of the bag already, plus it's a goofy method.
1 2 3 4 5 6 7 8 9
char ones[7], twos[7];
for(int k=1; k<=6; ++k)
{
ones[k-1] = '1';// write another '1' to the array
ones[k] = '\0';// move the string end forward
twos[k-1] = '2';// likewise
twos[k] = '\0';
cout << ones << twos;
}