code.jam - pixelcanvas (二)
来源:互联网 发布:索尼签约网络经销商 编辑:程序博客网 时间:2024/06/05 07:15
接上文题目,解二,c++的c语言实现
#include <iostream>#include <string>#include <cstdio>#pragma warning(disable : 4786) //Disable warning messages#include <vector>#include <fstream>using namespace std;int main(int argc, char *argv[]){char map[20][20];char command[10];int pox = 0;int poy = 0;int direction = 270;int i, j;for (i = 0; i < 20; i++)for (j = 0; j < 20; j++)map[i][j] = '.';freopen("input", "r", stdin);while( scanf("%s", &command) != -1){if (strcmp(command, "FORWARD") == 0){map[poy][pox] = '*';int len;scanf("%d", &len);switch(direction){case 0:while( len-- > 0){if (pox == 19) break;pox++;map[poy][pox] = 'X';}break;case 90:while( len-- > 0){if (poy == 0) break;poy--;map[poy][pox] = 'X';}break;case 180:while( len-- > 0){if (pox == 0) break;pox--;map[poy][pox] = 'X';}break;case 270:while( len-- > 0){if (poy == 19) break;poy++;map[poy][pox] = 'X';}break;}}else{direction+=90;direction= direction%360;}};for (i = 0; i < 20; i++){for (j = 0; j < 20; j++){printf("%c", map[i][j]);}printf("/n", map[i][j]);}return 0;}
- code.jam - pixelcanvas (二)
- code.jam - pixelcanvas
- google code jam 2009资格赛(pass)
- Google™ Code Jam - 中国编程挑战赛模拟题二
- Google Code Jam 2006
- Google China Code Jam
- code.jam - egg drops
- Google Code Jam
- [Code Jam] Alien Language
- 关于算法、code jam
- [Code Jam] Watersheds
- [Code Jam] Fair Warning
- [Code Jam] Theme Park
- Code Jam练习
- Google Code Jam 130914
- Code jam beta 2008
- [Code Jam] Crazy Rows
- [Code Jam] Millionaire
- 调查显示不恰当域名策略阻碍企业发展
- code.jam - pixelcanvas
- Oracle10G删除表的问题
- [观点]诺贝尔奖获得者对我的孩子说……
- Expat is an XML parser library
- code.jam - pixelcanvas (二)
- 设计中的光照效果原理
- myeclipse 6.0 快捷键 ALT+/的使用
- 使用ASP.Net Forms模式实现WebService身份验证
- SQL--JOIN之完全用法
- J2se小项目:坦克大战
- 新工作080624
- Symbian资源文件浅析
- ~~~经典爆笑口误~~~