How to output array as column/row NOT row/col

Hi guys,

...I need to output some information in a 2 dimensional array as [col][row] as opposed to [row][column], the information in the array cannot be manipulated to appease the [col][row] request either. Initially I thought it was just a matter of swapping the two, but I'm afraid not. I currently have:

array[xAxis][yAxis]

...but its still outputting as

array[yAxis][xAxis]

Please help me:(
closed account (3CXz8vqX)
What's your code?
@Ravenshade,

I sent you a PM, I can't post my code in the forum because its for school and I don't want people trying to copy my code. Thanks for helping:)
closed account (3CXz8vqX)
Yeah....how is it supposed to look?

Edit

An easy way to output rows instead of columns is to reverse all the data.

Edit2 You also have multiple arrays, so you're going to need to fill out the details of your question for me.

Edit3. Okay I see how it's meant to be laid out. Letters up the side, numbers across the top?
Last edited on
iHeartSTEM the point is knowledge sharing culture you should to post your code
When you

cin >> 3 0 2 0

...the movement is from row 3, col 0

I need to

cin >> 0 3 0 2

...and get the (3 0 2 0) output, but because it reads 0 3 0 2 as [row][col], and not [col][row] it does nothing because it thinks its an invalid move.


closed account (3CXz8vqX)
Why not just cin >> y1 >> x1 >> y2 >> x2? (both in sMovement and fMovement)

edit: instead of cin >> x1 >> y1 >> x2 >> y2;

Or am I being too simplistic?

...okay...simplistic, but I'm sure we can work around this....

...offs. You pain in the ass code. -_-

edit. Breakthrough!

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
//fMovement and sMovement
cout << "The foxes move: \n\n";

    //Changed to make more reader friendly (I had not a clue what I was doing until I put this in. 
   //feel free to chuck it. 
    cout << "Select Piece: \n\t Column:";
    cin >> y1;
    y1 = y1 - 1;  //Decrease for usability, user can input 1 to select a instead of 0. 
    cout << "\n\t Row:";
    cin >> x1;
    x1 = x1 - 1; //Decrease for usability as above. 1 = 1
    cout << "\n";

    cout << "Move to: \n\t Column:";
    cin >> y2;
    y2 = y2 - 1;
    cout << "\n\t Row:";
    cin >> x2;
    x2 = x2 - 1;

    //Now invert positioning. This is the important bit. 6 is one less than the array size so if you plan
   // to extend the field, you might want to use a pointer or const int var or something. 
    x1 = 6 - x1;
    x2 = 6 - x2;
Last edited on
Topic archived. No new replies allowed.