Dec 26, 2013 at 8:49am UTC
I want to print a matrix at a specific coordinate using gotoxy. Please help me where I went wrong?
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37
#include<iostream.h>
#include<conio.h>
void main()
{
clrscr();
int y;
int arr[2][2]={4,6,
5,5};
for (int k=0; k<=2; k++)
{
int x=5;
y=6;
gotoxy(x, y);
for (int i=0; i<2; i++)
{
for (int j=0; j<2; j++)
{
cout<<arr[i][j];
}
cout<<endl;
}
}
getch();
}
The out put is something like :
...... 46
55
//there are no dots in the program but this editor doesnt recognize the spaces.
I want the WHOLE matrix to be togther following that coordinate. Please tell me how I should increment the x, and y so that they remain in the same line.
Last edited on Dec 26, 2013 at 8:50am UTC
Dec 26, 2013 at 10:03am UTC
Questions on goto:
(I dont believe it's a part of the native library)
http://www.cplusplus.com/forum/general/33846/
How to make a goto:
http://www.cplusplus.com/forum/beginner/4234/
Duoas has done a fine job on the recreation of it.
Warning, header file "Windows.h" is necessary.
Or you can do it the good old fashion way:
2 For-Loops:
Y for newline;
X for space buffer;