走迷宫热身【控制点移动】
来源:互联网 发布:网络无法连接有个叹号 编辑:程序博客网 时间:2024/05/16 01:01
# include <iostream># include <conio.h>//getch()的使用必须有conio.h头文件using namespace std;int main(){char ch;int x, y;int x1, y1;int temp;int array[10][20] = {{1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1},{1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1},{1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1},{1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1},{1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1},{1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1},{1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1},{1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1},{1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1},};x = 4;y = 9;while(1){system("cls");for (int val = 0; val < 10; ++val){for (int flag = 0; flag < 20; ++flag){if (x == val && y == flag){cout << "·";}else{if (1 == array[val][flag]){cout << "#";}if (0 == array[val][flag]){cout << " ";}}}cout << endl;}x1 = x;y1 = y;ch = getch();//输入后直接执行代码,不暂停if ('w' == ch){if (1 != array[x-1][y])x = x - 1;}else if ('a' == ch){if (1 != array[x][y-1])y = y - 1;}else if ('d' == ch){if (1 != array[x][y+1])y = y + 1;}else if ('s' == ch){if (1 != array[x+1][y])x = x + 1;}temp = array[x1][y1];array[x1][y1] = array[x][y];array[x][y] = temp;}return 0;}
问题:
CPU使用率太高了!!!
- 走迷宫热身【控制点移动】
- 走迷宫
- 走迷宫
- 走迷宫
- 走迷宫
- 走迷宫
- 走迷宫
- 走迷宫
- 走迷宫
- 走迷宫
- 走迷宫
- 走迷宫
- 走迷宫
- 走迷宫
- 走迷宫
- 走迷宫
- 走迷宫
- 走迷宫
- 图片压缩 2
- C# 2.0 中的三个匿名函数特性
- arm assemble and gnu assemble
- VS2010的BUG?类名字问题,不变蓝色。
- Visual Studio中设置了另外的目标路径后,无法正常调试怎么办?
- 走迷宫热身【控制点移动】
- UVa 10099 The Tourist Guide
- windows服务
- 浅谈c语言中static关键字的作用
- winform项目打包安装一
- Android 解析XML文件的三种方式 DOM,SAX,PULL
- 深入体验JavaWeb开发内幕——进一步体味传统自定义标签的接口与实现类
- boost 编译和使用
- 程序员面试题精选100题(17)-把字符串转换成整数