Mar 6, 2013 at 2:49am UTC
asdqawda
Last edited on Mar 27, 2013 at 2:09pm UTC
Mar 6, 2013 at 2:58am UTC
add my if statement to your for loop. I think that will solve it.
also, open your outputFile.open("Printout.txt") before the for loop and:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
for (int i = 0; i < rows; i++)
{
for (int j = 0; j < columns; j++)
{
if (i%2 == 0)
{
cout << 0;
outputFile << 0;
}
else
{
cout << 1;
outputFile << 1;
}
}
cout << endl;
outputFile << endl;
}
Last edited on Mar 6, 2013 at 3:05am UTC
Mar 6, 2013 at 3:07am UTC
atriumheart,
Thank you so much! Your for loop was exactly what I needed. The last thing I need to do is print my program output to a text file. Does anybody know how I would be able to do this?
Mar 6, 2013 at 3:08am UTC
i edited my original post. It now fixes both of your problems.
Last edited on Mar 6, 2013 at 3:09am UTC
Mar 6, 2013 at 3:28am UTC
Thanks man, you're a hero. I just realized that instead of reading:
The original text file should contain the two numbers next to each other:
What changes would I need to make in order for the program to still work?
Sorry for all the questions.
Last edited on Mar 6, 2013 at 3:28am UTC
Mar 6, 2013 at 3:30am UTC
no space in between the numbers?
Mar 6, 2013 at 3:30am UTC
The numbers are separated by one space.
Mar 6, 2013 at 3:37am UTC
if there is a space between the numbers, then that shouldn't change a thing. If it was simply "57", then we would have to change some things.