POJ 2996 Help Me with the Game(模拟)
来源:互联网 发布:航海家软件免费版 编辑:程序博客网 时间:2024/06/12 14:33
http://poj.org/problem?id=2996
题目大意:
题目读了一年 国际象棋棋盘黑白相间
白色用 '.' 填充 黑色用 ':' 填充
白色棋子用大写字母表示 黑色棋子用小写字母表示
给你棋盘 求出棋子的坐标 (左下角为 a1 )
棋子按 KQRBNP 顺序输出
按列从小到大输出
同一白色棋子按行从小到大输出
同一黑色棋子按行从大到小输出
分析:
按输出顺序直接遍历图就好
AC代码:
#include <stdio.h>#include <string.h>char map[100][100];char str1[10]="KQRBNP";char str2[10]="kqrbnp";int main (){for (int i=0;i<17;i++){for (int j=0;j<8;j++){scanf("%*c%*c%c%*c",&map[i][j]) ;} getchar();getchar();}int count=0;int n=strlen(str1);printf ("White: ");for (int k=0;k<n;k++){for (int i=16;i>=0;i--){for (int j=0;j<8;j++){if(map[i][j]==str1[k]){if (count)printf (",");if(k!=n-1)printf ("%c",str1[k]);printf ("%c%d",j+'a',8-i/2);count++;}}}}putchar('\n');count=0;printf ("Black: ");for (int k=0;k<n;k++){for (int i=0;i<16;i++){for (int j=0;j<8;j++){if(map[i][j]==str2[k]){if (count)printf (",");if(k!=n-1)printf ("%c",str1[k]);printf ("%c%d",j+'a',(16-i+1)/2);count++;}}}}}
阅读全文
0 0
- poj 2996 Help Me with the Game(模拟)
- POJ 2996Help 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-2993-Help Me with the Game-模拟法
- POJ 2996-Help Me with the Game(模拟)
- POJ 2996 Help Me with the Game 国际象棋,模拟
- 模拟 Help Me with the Game 2996
- 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
- iOS 25个性能优化/内存优化常用方法
- php开启多线程下载
- 建立一个数组并比较他们的最值问题
- jsp常用核心标签实例
- logback配置示例
- POJ 2996 Help Me with the Game(模拟)
- java基础小知识
- C++程序开发过程
- list集合转对应类型的对象数组
- System.Net.Mail 发送邮件(带附件)
- Math数学函数
- mybatis的xml配置文件出现The content of elements must consist of well-formed character data or markup.
- SAP实施篇-轻松权限
- 大数据-配置PATH环境变量