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

Why is wrong on test 5#. Please help me...
Posted by NUUZ_1 4 Dec 2011 18:02
Please give me test 5# if you have,or send me your code (oa1990_10_17@mail.ru).
#include"iostream"
using namespace std;
void Tar(int K[][2]);
int main()
{
    int K[4][2],k=0;
    char s[4][5],c,ss[17];
    for(int i=1;i<=4;i++)
        for(int j=1;j<=4;j++)
        {
            cin>>c;
            if(c=='X')
            {
                K[k][0]=i;
                K[k][1]=j;
                k++;
            }
        }
        for(int i=0;i<4;i++)
        {
            cin>>s[i];
        }
        k=0;
        for(int i=1;i<5;i++)
        {
            ss[k]=s[K[0][0]-1][K[0][1]-1];
            k++;
            ss[k]=s[K[1][0]-1][K[1][1]-1];
            k++;
            ss[k]=s[K[2][0]-1][K[2][1]-1];
            k++;
            ss[k]=s[K[3][0]-1][K[3][1]-1];
            k++;
            for(int j=0;j<4;j++)
            {
                int t=K[j][0];
                K[j][0]=K[j][1];
                K[j][1]=5-t;
            }
            Tar(K);
        }
        ss[16]='\0';
        cout<<ss;
    return 0;
}
void Tar(int K[][2])
{
    for(int i=0;i<4;i++)
    {
        for(int j=i+1;j<4;j++)
        {
            if(K[j][0]<K[i][0])
            {
             int k=K[i][0],t=K[i][1];
             K[i][0]=K[j][0];
             K[i][1]=K[j][1];
             K[j][0]=k;K[j][1]=t;
            }
        }
    }
    for(int i=1;i<4;i++)
    {
        if(K[i][0]==K[i-1][0]&&K[i][1]<K[i-1][1])
        {
            int t=K[i][1];
            K[i][1]=K[i-1][1];
            K[i-1][1]=t;
        }
    }
}