POJ2996 help Me with the Game big simulation

Source: Internet
Author: User

http://blog.csdn.net/AXuan_K/article/details/37922039

Test instructions: Given a chessboard, the position of each piece is output. The row numbers indicate the column letters.

Note: 1. Uppercase letters indicate white, lowercase letters are black, and punctuation in the table is not used.

2, the checkerboard of the order and the matrix of the row opposite, that is, the matrix last behavior of the first line of the board.

3. White is arranged in ascending order of rows and columns.

4. Black chess lines are sorted in descending order of rows and ascending by column.

5, the final output without punctuation, the column letter is uppercase.

Idea: Arrays store the type of pawn, and white moves from the last line to the first line, and black moves from the first line to the last line. If there is a pawn, output its position.

1#include <cstdio>2#include <iostream>3#include <cstring>4#include <algorithm>5 using namespacestd;6 Chara[6]={'K','Q','R','B','N','P'};7 Charb[6]={'k','Q','R','b','N','P'};8 Charmap[ +][ +];9 Main ()Ten { One     inti,j,s1=0, s2=0, K; A      for(i=1; i<= -; i++) -     { -          for(j=1; j<= -; j + +) the         { -Cin>>Map[i][j]; -             if(map[i][j]=='P') -s1++; +             if(map[i][j]=='P') -s2++; +         } A     } atprintf"White :"); -      for(k=0;k<6; k++) -     { -          for(i= -; i>=1; i--) -         { -              for(j=1; j<= -; j + +) in             { -                 if(k<=4&&i%2==0&&j%4==3) to                 { +                     if(map[i][j]==A[k]) -                     { theprintf"%c%c%d,", A[k],'a'+ (j+1)/4-1,9-i/2); *                     } $                 }Panax Notoginseng                 if(k==5&&i%2==0&&j%4==3) -                 { the                     if(map[i][j]==A[k]) +                     { As1--; the                         if(s1==0) +printf"%c%d\n",'a'+ (j+1)/4-1,9-i/2); -                         Else $printf"%c%d,",'a'+ (j+1)/4-1,9-i/2); $                     } -                 } -             } the         } -     }Wuyiprintf"Black:"); the          for(k=0;k<6; k++) -     { Wu          for(i=1; i<= -; i++) -         { About              for(j=1; j<= -; j + +) $             { -                 if(k<=4&&i%2==0&&j%4==3) -                 { -                     if(map[i][j]==B[k]) A                     { +printf"%c%c%d,", A[k],'a'+ (j+1)/4-1,9-i/2); the                     } -                 } $                 if(k==5&&i%2==0&&j%4==3) the                 { the                     if(map[i][j]==B[k]) the                     { thes2--; -                         if(s2==0) inprintf"%c%d\n",'a'+ (j+1)/4-1,9-i/2); the                         Else theprintf"%c%d,",'a'+ (j+1)/4-1,9-i/2); About                     } the                 } the             } the         } +     } -}
View Code

POJ2996 help Me with the Game big simulation

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.