Can u give me an idea on how to write this program

i have a homework to output the array below


0 0 0 2 0 0 0
0 0 2 4 6 0 0
0 2 4 6 8 10 0
2 4 6 8 10 12 14

Note I have to make this matrix without using input statement but i have no idea to that. So if someone can give me an idea it would be appreciated.

Thanx in advance.
Last edited on
Here's the solution!
1
2
3
4
5
6
7
#include <iostream>
int main ()
{ 
	std::cout <<"0 0 0 2 0 0 0\n0 0 2 4 6 0 0\n0 2 4 6 8 10 0\n2 4 6 8 10 12 14\n";
	std::cin.ignore(); //PAUSE
	return 0;
}


...okay, I'm mean. Sorry. Really, I'm sorry. :(

However, look closely. The matrix is 7 by 4, and the centermost number increases by two each time. None of the numbers are less than zero, and if the number to the left or the right is non-zero, then on the next pass of a loop, the number will increase by two more than the number to its left, checking from left to right. Sort-of. Do you get the idea? :)

HINT: Use an array.

EDIT: Typo.

-Albatross
Last edited on
hhh nice solution.

Thanx for the reply, yeah i think i got the idea. now I will try to write a code i hope i will succeed :D

Topic archived. No new replies allowed.