POJ 2996 Help Me with the Game(模拟)
2012-11-25 21:34
423 查看
题目链接
注意优先级问题,样例看清楚,过了样例应该就能看出优先级不一样了。
注意优先级问题,样例看清楚,过了样例应该就能看出优先级不一样了。
#include <cstdio> #include <cstring> #include <cmath> using namespace std; char str[13] = "KQRBNP"; int main() { char p[101][101]; int i,j,k,z; for(i = 0;i <= 16;i ++) { gets(p[i]); } printf("White: "); z = 1; for(i = 0;i <= 5;i ++) { for(j = 16;j >= 1;j --)//优先级问题,和下面不一样。 { for(k = 1;k <= 32;k ++) { if(p[j][k] == str[i]) { if(z) { if(i != 5) printf("%c%c%d",str[i],k/4+'a',8-j/2); else printf("%c%d",k/4+'a',8-j/2); z = 0; } else { if(i != 5) printf(",%c%c%d",str[i],k/4+'a',8-j/2); else printf(",%c%d",k/4+'a',8-j/2); } } } } } printf("\n"); printf("Black: "); z = 1; for(i = 0;i <= 5;i ++) { for(j = 1;j <= 16;j ++) { for(k = 1;k <= 32;k ++) { if(p[j][k] == str[i]+'a'-'A') { if(z) { if(i != 5) printf("%c%c%d",str[i],k/4+'a',8-j/2); else printf("%c%d",k/4+'a',8-j/2); z = 0; } else { if(i != 5) printf(",%c%c%d",str[i],k/4+'a',8-j/2); else printf(",%c%d",k/4+'a',8-j/2); } } } } } printf("\n"); return 0; }
相关文章推荐
- poj 2996 Help Me with the Game(模拟)
- 快速切题 poj 2996 Help Me with the Game 棋盘 模拟 暴力 难度:0
- 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 模拟
- 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 模拟
- POJ 2996-Help Me with the Game(模拟-描述棋盘中KQRBNP的位置)
- POJ 2996 Help Me with the Game 国际象棋,模拟
- poj-2996-2993-Help Me with the Game-模拟法