关于#c++#的问题:随机分布几张扑克牌在3行,让玩家选中一个牌,告诉程序这个牌在哪行,3次后程序判断出是哪张扑克牌在别处看到的代码,但是我个人有很多地方没看明白:(个人是初学者

是一个小游戏,随机分布几张扑克牌在3行,让玩家选中一个牌,告诉程序这个牌在哪行,3次后程序判断出是哪张扑克牌
在别处看到的代码,运行后结果完全没问题,但是我个人有很多地方没看明白:(个人是初学者,看不懂代码,见谅!)
如图,有时这个扑克牌是没法对齐的,我试过把空格变成“\t”也不行,这个要怎么对齐?

img

然后就是具体流程,比如三维数组那里,抱歉我个人真的没看懂,有人能帮忙详细讲解下吗
代码如下:

#include
#include
#include
using namespace std;

void pai(int a)
{
    int i, j;
    i = a / 13;           //让i为0~4的数,j为0~12的数;
    j = a % 13;              //i用来判断花色(a/b/c/d),j用来判断数字和字母;
    if (j != 9 && i< 4)      //
    {
        cout << "   ";
    }
    switch (i)
    {
    case 0:
        cout << "a-";
        break;

    case 1:
        cout << "b-";
        break;

    case 2:
        cout << "c-";
        break;

    case 3:
        cout << "d-";
        break;

    case 4:
        cout << "King-";     //特色情况King,只有King1和King2两种情况
        break;

    default:
        break;
    }
    if (i < 4)
    {
        if (j > 0 && j < 10)
            cout << j + 1;
        else if (j == 10)     //将10~12转化为J、Q、K,0转化为A
        {
            cout << "J";
        }
        else if (j == 11)
        {
            cout << "Q";
        }
        else if (j == 12)
        {
            cout << "K";
        }
        else if(j==0)
        {
            cout << "A";
        }
    }
    else
    {
        cout << j + 1;
    }
    cout << "   ";
}


int getline()
{
    int line;
    cout << "-----------------------------------------------------------------------------" << endl;
    cout << "Remember a card,and tell me what line it reside in(1/2/3):";
    cin >> line;
    while (!(line == 1 || line == 2 || line == 3))
    {
        cout << "Input format error,please reenter: ";
        cin >> line;
    }
    return line;
}


int main()
{
    srand((unsigned int)time(NULL));     
    int arr[3][3][3];
    int i = 0, j = 0, n = 0;
    int a, b, c,line1, line2, line3;
    bool judge;

    for(i=0;i<3;i++)
        for(j=0;j<3;j++)
            for (n = 0; n < 3; n++)
            {
                judge = true;
                while (judge)
                {
                    judge = false;
                    arr[i][j][n] = rand() % 27;
                    for (a = 0; a < i - 1; a++)
                        for (b = 0; b < 3; b++)
                            for (c = 0; c < 3; c++)
                                if (arr[a][b][c] == arr[i][j][n])
                                    judge = true;

                    for (b = 0; b < j - 1; b++)
                        for (c = 0; c < 3; c++)
                            if (arr[i][b][c] == arr[i][j][n])
                                judge = true;

                    for (c = 0; c < n - 1; c++)
                        if (arr[i][j][c] == arr[i][j][n])
                            judge = true;
                }
            }
                
    cout << "-----------------------------------------------------------------------------" << endl;
                for (i = 0; i < 3; i++)
                {
                    cout << "Line " << i + 1 << ": ";
                    for (j = 0; j < 3; j++)
                        for(n = 0; n < 3; n++)
                        pai(arr[i][j][n]);
                    cout << endl;
                }
                line1 = getline();

                cout << "-----------------------------------------------------------------------------" << endl;
                for (j = 0; j < 3; j++)
                {
                    cout << "Line " << j + 1 << ": ";
                    for (n = 0; n < 3; n++)
                        for (i = 0; i < 3; i++)
                            pai(arr[i][j][n]);
                    cout << endl;
                }
                line2 = getline();

                cout << "-----------------------------------------------------------------------------" << endl;
                for (n = 0; n < 3; n++)
                {
                    cout << "Line " << n + 1 << ": ";
                    for (i = 0; i < 3; i++)
                        for (j = 0; j < 3; j++)
                            pai(arr[i][j][n]);
                    cout << endl;
                }
                line3 = getline();

                cout << "-----------------------------------------------------------------------------" << endl;
                cout << "Your remembered card is:";
                pai(arr[line1-1][line2-1][line3-1]);       
                cout << endl;
                return 0;

            }

我运行了一下,是对齐的呀