测试了一个游戏的代码
来源:互联网 发布:php防止ddos 编辑:程序博客网 时间:2024/06/06 00:22
<pre name="code" class="cpp">//bug last line can not swap with n-1//http://www.zhihu.com/question/22547591/ #include<iostream>using namespace std; int ii=0;int Find( char x,int size,int zeroIndex){ switch (x) { case 's': //上移 就是找到零下面的那个数字的位置 也就是序号增加一行 也就是+4 { if ( zeroIndex<size - 4) { return zeroIndex + 4; } } break; case 'x': //下移 {// if (zeroIndex<size-4 && zeroIndex>3) if ( zeroIndex>3) { return zeroIndex - 4; } } break; case 'c': { if ( zeroIndex%4!=0 ) { return zeroIndex - 1; } } break; case 'z': //左移 主要是判断空白是否在右边缘 { if (zeroIndex%4!=3) { return zeroIndex + 1; } } break; default: break; } return -1;} //交换数组中zero和next的位置void SwapIndex(int *ary,int zero, int next){ if (-1 == next) { return ; } int t = ary[zero]; ary[zero] = ary[next]; ary[next] = t; } void Update(int *ary, int size,char com){ int zeroIndex = 0; //零的序号 for (int i = 0.; i< size ; i++) { if (ary[i] == 0) { zeroIndex = i; break; } } int nextIndex = Find(com,size,zeroIndex); //获取跟零相邻(根据com不同 取上下左右)的那个数字的序号 SwapIndex(ary,zeroIndex,nextIndex); } void Show(int *ary, int size){ ii++; for (int i = 0 ; i <size; i++) { if(i % 4 == 0) //假设每行4个数字 { cout<<endl<<endl; } if (ary[i]!=0) { cout<<"\t"<<ary[i]; } else { cout<<"\t"; } } //cout<<endl<<"请输入方向(1234):"; cout<<endl<<" "<<ii<<endl<<"请输入方向(sxzc):";} bool ProcessCommand(int *ary, int size, char com){ // system("cls"); Update(ary,size,com); //更新地图 Show(ary,size); //显示新的地图 return true;} char GetCommand() //假设只返回4个值 代表四个方向{//int test = 1;char test='s';cin>>test;//先测试一下return test;} void Process(int *ary, int size){ /// int com = 0; char com='s'; while(ProcessCommand(ary,size,com)) { com = GetCommand(); } } int pintu(){ int ary[16]; //数字0 代表空白 for (int i=0;i<16; i++) { ary[i] = i; } Process(ary,16); return 0;}
0 0
- 测试了一个游戏的代码
- 一个robotium的测试代码
- 一个robotium的测试代码
- 一个robotium的测试代码
- 招了一大群学生的游戏代码
- 一个在线测试Html、脚本代码的网站!(不用建文件了)
- 一种奇怪的错误,执行一个junit测试用例,代码却执行了很多遍
- Java游戏测试代码
- 今天发现一个变态的游戏代码
- 一个猜数字游戏代码的改进
- 代码笔记 | 一个简单的游戏框架
- 今天做了一个有趣的测试
- 为了给自己开发一个支持 fastcgi 的 http server 做准备。剥离了 nanoweb 的 fastcgi 接口部分代码。测试了下。 成功了
- 一个标准的REST API测试代码
- 测试一个带图带代码的内容文章
- 用Vue写的一个计时游戏,来源于脚本之家的代码,自己写了注释,修改了部分地方
- 一个菜鸟半年的游戏测试的工作心得
- 不会代码的我,让超模走进了我的游戏...
- Activity AndroidManifest的启动模式
- 灯塔(LightHouse)
- 使用国内的镜像服务器更新android sdk
- erlang性能监控
- PHP获取select值
- 测试了一个游戏的代码
- 7. Minimum Depth of Binary Tree-LeetCode
- Android 强制横屏
- leetcode——54——Spiral Matrix
- Android程序崩溃异常处理之自动发送邮件
- 排序(Java语言)——冒泡排序
- 从零开始学_JavaScript_系列(十)——dojo(3)(GRID表格创建、样式、列宽可变、排序、过滤器)
- 【BestCoder Round #77 (div.2)】HDU5650so easy
- python判断变量类型