Description
This problem is a reverse case of the problem 2996. You are given the output of the problem H and your task is to find the corresponding input.
Input
According to output of problem 2996.
Output
According to input of problem 2996.
Sample Input
White: Ke1, Qd1, Ra1, Rh1, Bc1, Bf1, Nb1, a2, c2, d2, f2, g2, h2, a3, e4
Black: Ke8, Qd8, Ra8, Rh8, Bc8, Ng8, Nc6, a7, b7, c7, d7, e7, f7, h7, h6
Sample Output
+ --- +
|. R. |: |. B. |: q: |. k. |: |. n. |: r: |
+ --- +
|: P: |. p. |: |. p. |
+ --- +
|... |: |. N. |: |... |: p: |
+ --- +
|: |... |
+ --- +
|... |: |. P. |: |... |: |
+ --- +
|: P: |... |
+ --- +
|. P. |: |. P. |: P: |... |: P: |. P. |: P: |
+ --- +
|: R: |. N. |: B: |. Q. |: K: |. B. |: |. R. |
+ --- +
This question uses the most stupid method, and the result is repeat twice. After debugging for a long time, the principle will not be mentioned...
[Cpp]
# Include <iostream>
# Include <stdio. h>
# Include <stdlib. h>
# Include <string. h>
Using namespace std;
Char a [18] [34] = {
{'+', '-', '+', '-', '+ ', '-', '+', '-', '+ ','-','-', '-', '+ ', '-', '+ '},
{'| ','. ','. ','. ',' | ',': ',' | ','. ','. ','. ',' | ',': ',' | ','. ','. ','. ',' | ',': ',' | ','. ','. ','. ',' | ',': ',' | '},
{'+', '-', '+', '-', '+ ', '-', '+', '-', '+ ','-','-', '-', '+ ', '-', '+ '},
{'|', ':', '| ','. ','. ','. ',' | ',': ',' | ','. ','. ','. ',' | ',': ',' | ','. ','. ','. ',' | ',': ',' | ','. ','. ','. ',' | '},
{'+', '-', '+', '-', '+ ', '-', '+', '-', '+ ','-','-', '-', '+ ', '-', '+ '},
{'| ','. ','. ','. ',' | ',': ',' | ','. ','. ','. ',' | ',': ',' | ','. ','. ','. ',' | ',': ',' | ','. ','. ','. ',' | ',': ',' | '},
{'+', '-', '+', '-', '+ ', '-', '+', '-', '+ ','-','-', '-', '+ ', '-', '+ '},
{'|', ':', '| ','. ','. ','. ',' | ',': ',' | ','. ','. ','. ',' | ',': ',' | ','. ','. ','. ',' | ',': ',' | ','. ','. ','. ',' | '},
{'+', '-', '+', '-', '+ ', '-', '+', '-', '+ ','-','-', '-', '+ ', '-', '+ '},
{'| ','. ','. ','. ',' | ',': ',' | ','. ','. ','. ',' | ',': ',' | ','. ','. ','. ',' | ',': ',' | ','. ','. ','. ',' | ',': ',' | '},
{'+', '-', '+', '-', '+ ', '-', '+', '-', '+ ','-','-', '-', '+ ', '-', '+ '},
{'|', ':', '| ','. ','. ','. ',' | ',': ',' | ','. ','. ','. ',' | ',': ',' | ','. ','. ','. ',' | ',': ',' | ','. ','. ','. ',' | '},
{'+', '-', '+', '-', '+ ', '-', '+', '-', '+ ','-','-', '-', '+ ', '-', '+ '},
{'| ','. ','. ','. ',' | ',': ',' | ','. ','. ','. ',' | ',': ',' | ','. ','. ','. ',' | ',': ',' | ','. ','. ','. ',' | ',': ',' | '},
{'+', '-', '+', '-', '+ ', '-', '+', '-', '+ ','-','-', '-', '+ ', '-', '+ '},
{'|', ':', '| ','. ','. ','. ',' | ',': ',' | ','. ','. ','. ',' | ',': ',' | ','. ','. ','. ',' | ',': ',' | ','. ','. ','. ',' | '},
{'+', '-', '+', '-', '+ ', '-', '+', '-', '+ ','-','-', '-', '+ ', '-', '+ '}};
Int main ()
{
Int I, j;
/* For (I = 0; I <17; I ++)
{
For (j = 0; j <33; j ++)
{
Cout <a [I] [j];
}
Cout <endl;
}*/
Char white [1000];
Char black [1000];
Int lenw, lenb;
Gets (white );
Gets (black );
// Cout <white <endl;
// Cout <black <endl;
Lenw = strlen (white );
Lenb = strlen (black );
/* For (I = 0; I <17; I ++)
{
For (j = 0; j <33; j ++)
{
Cout <a [I] [j];
}
Cout <endl;
}*/
I = 7;
For (I = 7; I <lenw; I + = 4)
{
If (white [I]> = 65 & white [I] <= 90) // determines whether the 8th characters are uppercase letters.
A [(9-(white [I + 2]-'0') * 2-1] [(white [I + 1]-'A ') * 4 + 2] = white [I];
Else // undo it, indicating that only P is followed
Break;
}
For (j = I; j <lenw; j + = 3)
{
If (white [j]> = 97 & white [j] <= 122) // check whether there are any lowercase letters.
A [(9-(white [j + 1]-'0') * 2-1] [(white [j]-'A ') * 4 + 2] = 'P ';
Else // if there is no more, it will be over.
Break;
}
I = 7; // same as upper-level ha, not arrogant.
For (I = 7; I <lenb; I + = 4)
{
If (black [I]> = 65 & black [I] <= 90)
A [(17-(black [I + 2]-'0') * 2)] [(black [I + 1]-'A ') * 4 + 2] = black [I] + 32;
Else
Break;
}
For (j = I; j <lenb; j + = 3)
{
If (black [j]> = 97 & black [j] <= 122)
A [(17-(black [j + 1]-'0') * 2)] [(black [j]-'A ') * 4 + 2] = 'P ';
Else
Break;
}
For (I = 0; I <17; I ++)
{
For (j = 0; j <33; j ++)
{
Cout <a [I] [j];
}
Cout <endl;
} Www.2cto.com
Return 0;
}
Author: CSUST_ACM