ENG  RUSTimus Online Judge
Online Judge
Problems
Authors
Online contests
About Online Judge
Frequently asked questions
Site news
Webboard
Links
Problem set
Submit solution
Judge status
Guide
Register
Update your info
Authors ranklist
Current contest
Scheduled contests
Past contests
Rules
back to board

Discussion of Problem 1712. Cipher Grille

test#1. Why?
Posted by Igor 26 Feb 2019 13:29
 #include <iostream>
using namespace std;

char paper[4][4], pass[4][4],rPass[16],TempPaper[4][4];
int v, i, j;

void check(char paper[4][4], char pass[4][4])
{
    for (int j = 0; j < 4; j++)// X/.
    {
        for (int i = 0; i < 4; i++)
        {
            if (paper[j][i] == 'X')
            {
                rPass[v] = pass[j][i];
                v++;
            }

        }
    }
}

int main()
{
    for (int j = 0; j < 4; j++) //paper cin
    {
        for (int i = 0; i < 4; i++)
        {
            cin >> paper[j][i];
        }
    }

    for (int j = 0; j < 4; j++)//зашифрованый пароль
    {
        for (int i = 0; i < 4; i++)
        {
            cin >> pass[j][i];
        }
    }
    for (int j = 0; j < 4; j++)//temp
    {
        for (int i = 0; i < 4; i++)
        {
            TempPaper[j][i] = paper[j][i];
        }
    }
    check(paper, pass);
    for (i = 0; i < 4; i++)
    {
        for (j = 0; j < 4; j++)
        {
            int t=0, y;
            if (j == 0)
            {
                int u = 3;
                for (y = 0; y < 4; y++)
                {
                    paper[t][u] = TempPaper[0][y];
                    t++;
                }
            }
            if (j == 1)
            {
                int u = 2;
                for (y = 0; y < 4; y++)
                {
                    paper[t][u] = TempPaper[1][y];
                    t++;
                }
            }
            if (j == 2)
            {
                int u = 1;
                for (y = 0; y < 4; y++)
                {
                    paper[t][u] = TempPaper[2][y];
                    t++;
                }
            }
            if (j == 3)
            {
                int u = 0;
                for (y = 0; y < 4; y++)
                {
                    paper[t][u] = TempPaper[3][y];
                    t++;
                }
            }
        }
        check(paper, pass);
        for (int j = 0; j < 4; j++)
        {
            for (int i = 0; i < 4; i++)
            {
                TempPaper[j][i] = paper[j][i];
            }
        }
        }
    return 0;
}