qasdas

Mar 6, 2013 at 2:49am
closed account (3UMLy60M)
asdqawda
Last edited on Mar 27, 2013 at 2:09pm
Mar 6, 2013 at 2:58am
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
Mar 6, 2013 at 3:07am
closed account (3UMLy60M)
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
i edited my original post. It now fixes both of your problems.
Last edited on Mar 6, 2013 at 3:09am
Mar 6, 2013 at 3:28am
closed account (3UMLy60M)
Thanks man, you're a hero. I just realized that instead of reading:
5
7


The original text file should contain the two numbers next to each other:
5 7


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
Mar 6, 2013 at 3:30am
no space in between the numbers?
Mar 6, 2013 at 3:30am
closed account (3UMLy60M)
The numbers are separated by one space.
Mar 6, 2013 at 3:37am
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.
Topic archived. No new replies allowed.