题目描述:算法竞赛入门经典习题3-5

题目思路:模拟题

#include <stdio.h>
#include <string.h>
#define maxn 55
char gird[maxn][maxn] ;
char cmd[maxn] ;
int blank_x,blank_y ;
int main(int argc, char *argv[])
{ int flag = ;
for(int i=;i<;i++)
gets(gird[i]) ;
for(int i=;i<;i++)
for(int j=;j<;j++)
if(gird[i][j]==' '){
blank_x = i;
blank_y = j;
}
while(gets(cmd)){
int len = strlen(cmd) ;
for(int i=;i<len;i++){
if(cmd[len-] == '' || cmd[i] == 'A' || cmd[i] == 'R' || cmd[i] == 'B' || cmd[i] == 'L' ){
if(cmd[i] == 'A' && blank_x != )
{
gird[blank_x][blank_y] = gird[blank_x-][blank_y];
gird[--blank_x][blank_y] = ' ';
}
if(cmd[i] == 'R' && blank_y != )
{
gird[blank_x][blank_y] = gird[blank_x][blank_y+];
gird[blank_x][++blank_y] = ' ';
}
if(cmd[i] == 'B' && blank_x != )
{
gird[blank_x][blank_y] = gird[blank_x+][ blank_y];
gird[++blank_x][ blank_y] = ' ';
}
if(cmd[i] == 'L' && blank_y != )
{
gird[blank_x][blank_y] = gird[blank_x][ blank_y-];
gird[blank_x][--blank_y] = ' ';
} }
else flag = ;
}
if(flag)
{
for(int i = ; i < ; i++)
{
printf("%c %c %c %c %c\n", gird[i][], gird[i][], gird[i][], gird[i][], gird[i][]);
}
}
else
printf("This puzzle has no final configuration.\n"); }
return ;
}

谜题 (Puzzle,ACM/ICPC World Finals 1993,UVa227)的更多相关文章

  1. 习题3-5 谜题(Puzzle, ACM/ICPC World Finals 1993, UVa227)

    #include<stdio.h> #include<string.h> char s[5][5]; int main() { while(gets(s[0])) { int ...

  2. ACM - ICPC World Finals 2013 C Surely You Congest

    原题下载:http://icpc.baylor.edu/download/worldfinals/problems/icpc2013.pdf 题目翻译: 试题来源 ACM/ICPC World Fin ...

  3. ACM - ICPC World Finals 2013 A Self-Assembly

    原题下载 : http://icpc.baylor.edu/download/worldfinals/problems/icpc2013.pdf 这道题其实是2013年我AC的第一道题,非常的开心,这 ...

  4. ACM - ICPC World Finals 2013 F Low Power

    原题下载:http://icpc.baylor.edu/download/worldfinals/problems/icpc2013.pdf 题目翻译: 问题描述 有n个机器,每个机器有2个芯片,每个 ...

  5. ACM - ICPC World Finals 2013 I Pirate Chest

    原题下载:http://icpc.baylor.edu/download/worldfinals/problems/icpc2013.pdf 题目翻译: 问题描述 海盗Dick受够了在公海上厮杀.抢劫 ...

  6. ACM - ICPC World Finals 2013 H Матрёшка

    原题下载:http://icpc.baylor.edu/download/worldfinals/problems/icpc2013.pdf 题目翻译: 问题描述 俄罗斯套娃是一些从外到里大小递减的传 ...

  7. ACM - ICPC World Finals 2013 D Factors

    原题下载:http://icpc.baylor.edu/download/worldfinals/problems/icpc2013.pdf 题目翻译: 问题描述 一个最基本的算数法则就是大于1的整数 ...

  8. ACM - ICPC World Finals 2013 B Hey, Better Bettor

    原题下载:http://icpc.baylor.edu/download/worldfinals/problems/icpc2013.pdf 这题真心的麻烦……程序不长但是推导过程比较复杂,不太好想 ...

  9. [算法竞赛入门经典]Message Decoding,ACM/ICPC World Finals 1991,UVa213

    Description Some message encoding schemes require that an encoded message be sent in two parts. The ...

随机推荐

  1. HDU 2092 (将表达式变成一元二次方程形式)

    传送门: http://acm.hdu.edu.cn/showproblem.php?pid=2092 整数解 Time Limit: 1000/1000 MS (Java/Others)    Me ...

  2. 【转载】iPhone屏幕尺寸、分辨率及适配

    iPhone屏幕尺寸.分辨率及适配 转载http://m.blog.csdn.net/article/details?id=42174937 1.iPhone尺寸规格 iPhone 整机宽度Width ...

  3. java 编写小工具 尝试 学习(一)

    1.单片机 调试经常 需要  用 串口 工具 发送 一些 特定的  协议或者 命令,每次要 翻译  写成 2进制 很麻烦 ,因此 打算自己用 java 写一个 工具 方便自己  调试,2017年3月2 ...

  4. php auto_prepend_file和auto_append_file的妙用

    这是一个鲜为人知的设置! auto_prepend_file 和 auto_append_file 是在php.ini中进行配置的2个参数,auto_prepend_file 表示在php程序加载第一 ...

  5. asp.net mvc5 step by step(一)——CURD增删查改Demo

    1.  新建一个项目:

  6. 关于Date的冷门知识记录

    最近在做项目的时候,用到了Date.toLocaleString来处理当前日期.在这之前,我都是通过get*等方式来获取数据进行拼接.无意间,发现了toLocaleString方法.遂想写一篇文章来记 ...

  7. parsing XML document from class path resource [applicationtext.xml]; nested exception is java.io.FileNotFoundException: class path resource [applicationtext.xml] cannot be opened because it does not e

    控制台异常: parsing XML document from class path resource [applicationtext.xml]; nested exception is java ...

  8. Spring的入门学习笔记 (注解)

    Spring的bean管理(注解) 注解 1.代码里面特殊标记(ep:@Test),使用注解完成一些相关功能 2.注解写法 @注解名称(属性名称=属性值) 3.可以用在类,方法,属性上都可以 4.Sp ...

  9. Spring的扩展

    Spring中引用属性文件 JNDI数据源 Spring中Bean的作用域 Spring自动装配 缺点

  10. python闭包的概念及使用

    闭包:在函数里定义了另外一个函数(函数嵌套),内函数里运用了外函数的变量,外函数返回内函数的函数引用(函数名). nonlocal 的使用:闭包内部函数可直接调用外部函数的变量,如果修改需要使用non ...