poj2996Help Me with the Game
来源:互联网 发布:二手软件 编辑:程序博客网 时间:2024/06/13 03:38
http://poj.org/problem?id=2996
模拟
#include <stdio.h>typedef struct node{ int x; char y; char ch;}Piece;Piece wPiece[16],bPiece[16];int n1,n2;char square[17][33];void findbp(char p){ int i,j; for(i=1;i<=7;i++) { if(square[i][0]=='+') continue; for(j=0;j<32;j++) if(square[i][j]==p) { bPiece[n1].ch=p-32; bPiece[n1].x=9-(i+1)/2;//转换行号 bPiece[n1].y=(j+2)/4+96;//转换列号 n1++; } } }void findwp(char p){ int i,j; for(i=15;i>=9;i--) { if(square[i][0]=='+') continue; for(j=0;j<32;j++) if(square[i][j]==p) { wPiece[n2].ch=p; wPiece[n2].x=9-(i+1)/2;//转换行号 wPiece[n2].y=(j+2)/4+96;//转换列号 n2++; } } }void chessNotation(Piece array[],int n)//输出象棋谱 { int i; for(i=0;i<n;i++) { if(array[i].ch!='P') { printf("%c%c%d,",array[i].ch,array[i].y,array[i].x); continue; } if(i==n-1) printf("%c%d\n",array[i].y,array[i].x); else printf("%c%d,",array[i].y,array[i].x); }}int main(){ int i,j,t; char bp[6]={'k','q','r','b','n','p'}; char wp[6]={'K','Q','R','B','N','P'}; for(i=0;i<17;i++) scanf("%s",square[i]); n1=0; for(t=1;t<=6;t++)//6 times findbp(bp[t-1]); n2=0; for(t=1;t<=6;t++)//6 times findwp(wp[t-1]); printf("White: "); chessNotation(wPiece,n2); printf("Black: "); chessNotation(bPiece,n1); return 0;}</span>
0 0
- POJ2996Help Me with the Game
- poj2996Help Me with the Game
- POJ2996Help Me with the Game
- POJ2996Help Me with the Game
- Help Me with the Game
- Help Me with the Game
- Help Me with the Game
- Poj 2996 Help Me with the Game
- POJ 2996 Help Me with the Game
- poj 2996 Help Me with the Game
- poj 2996 Help Me with the Game
- POJ 2996 Help Me with the Game
- POJ 2996 Help Me with the Game
- POJ 2996 Help Me with the Game
- poj2996 Help Me with the Game
- poj 2996 Help Me with the Game
- poj2996--Help Me with the Game
- poj-2996 Help Me with the Game
- C/C++中的%010u是个什么东东?
- 面象对象与实际的结合
- 常见的DDos攻击手段
- 深入 Java 调试体系
- java同时启动多个线程
- poj2996Help Me with the Game
- Collection集合介绍
- Hibernate表间级联
- 字符编码笔记:ASCII,Unicode和UTF-8
- Maven+struts2+eclipse环境搭建
- poj2993Emag eht htiw Em Pleh
- 理解Java对象序列化
- __stdcall、__cdcel和__fastcall三者的区别
- 【转】CSS3的自定义字体@font-face:如何将icon变成字体?