我编写了一个简单的地图绘图程序,但有一些我无法识别的错误。
- 该错误仅在 X 坐标为正时发生,在其为负值时正常。
 - 当我的范围仅为 11 时,为什么会打印最后一列点?
 
这是代码:
int xRange = 11;
int yRange = 11;
string _space = "   ";
string _star = " * ";
for( int x = xRange; x > 0; x-- )
{
    for( int y = 0; y < yRange; y++ )
    {
        int currentX = x - 6;
        int currentY = y - 5;
        //demo input
        int testX = 2; //<----------ERROR for +ve int, correct for -ve
        int testY = -4; //<-------- Y is working ok for +ve and -ve int
        //Print x-axis
        if( currentY == 0 )
        {
            if( currentX < 0 )
                cout << currentX << " ";
            else
                cout << " " << currentX << " ";
        }
        //Print y-axis
        if( currentX == 0 )
        {
            if( currentY < 0 )
                cout << currentY << " ";
            else
                //0 printed in x axis already
                if( currentY != 0 )
                    cout << " " << currentY << " ";
        }
        else if( currentY == testX and currentX == testY )
            cout << _star;
        else
            cout << " . ";
    }
    //print new line every completed row print
    cout << endl;
}
演示输入的输出(x:2,y:-4):(它在 3 处显示 x,这是错误的)
 .  .  .  .  .  5  .  .  .  .  .  . 
 .  .  .  .  .  4  .  .  .  .  .  . 
 .  .  .  .  .  3  .  .  .  .  .  . 
 .  .  .  .  .  2  .  .  .  .  .  . 
 .  .  .  .  .  1  .  .  .  .  .  . 
-5 -4 -3 -2 -1  0  1  2  3  4  5 
 .  .  .  .  . -1  .  .  .  .  .  . 
 .  .  .  .  . -2  .  .  .  .  .  . 
 .  .  .  .  . -3  .  .  .  .  .  . 
 .  .  .  .  . -4  .  .  *  .  .  . 
 .  .  .  .  . -5  .  .  .  .  .  .
演示输入的输出(x:-2,y:4):
 .  .  .  .  .  5  .  .  .  .  .  . 
 .  .  .  *  .  4  .  .  .  .  .  . 
 .  .  .  .  .  3  .  .  .  .  .  . 
 .  .  .  .  .  2  .  .  .  .  .  . 
 .  .  .  .  .  1  .  .  .  .  .  . 
-5 -4 -3 -2 -1  0  1  2  3  4  5 
 .  .  .  .  . -1  .  .  .  .  .  . 
 .  .  .  .  . -2  .  .  .  .  .  . 
 .  .  .  .  . -3  .  .  .  .  .  . 
 .  .  .  .  . -4  .  .  .  .  .  . 
 .  .  .  .  . -5  .  .  .  .  .  .
任何人都可以帮助确定我的代码中的两个问题吗?谢谢。