旋转吧巨人
来源:互联网 发布:重生之数据人生txt 编辑:程序博客网 时间:2024/04/28 17:26
// Spin.cpp : Defines the entry point for the console application.#include "stdafx.h"#include "iostream"#include "stdio.h"#define M 6#define K 10//internal -> outtervoid spin(int n){int **a = new int *[10];//direction flagint flag = 1;//the initial numberint number =1;int i,j;//initializationfor(int m = 0; m < K; m++){ a[m] = new int[K] ; }for(i = 0;i < K;i++){for(j = 0;j < K;j++){a[i][j] = 0;} }//judge odd or evenif(K & 1){ //oddi = K/2;j = K/2;}else{ //eveni = K/2 -1;j = K/2 -1;}while(true){ //judge the border if(number > n){ break;}//fill the blank if the space hasn't been filled!if(a[i][j] == 0){ a[i][j] = number++;}//from left to rightif(flag ==1 ){if(a[i+1][j] == 0){ //fill the bottom i++; flag = 2;}else{ //or fill the rightj++;}}//from upward to bottomif(flag == 2){if(a[i][j-1] == 0){ //fill the left j--;flag = 3;}else{ //or fill the bottom i++; }}//from right to leftif(flag == 3){if(a[i-1][j] == 0){ //fill the upward i--; flag = 4;}else{ //or fill the left j--; }}//from bottom to upwardif(flag == 4){if(a[i][j+1] ==0 ){ //fill the right j++; flag =1;}else{ //or fill the upward i--; }}}for(i =0;i< K;i++){for(j = 0; j< K;j++){if(a[i][j]!=0){printf("%d",a[i][j]);}else{ printf("X");}}printf("\n");}}int _tmain(int argc, _TCHAR* argv[]){spin(4);printf("please input a random number:\n");//while(scanf_s("%d",&x)!=EOF){//}return 0;}
0 0
- 旋转吧巨人
- 看巨人,学巨人,超巨人
- 蓝色巨人
- 《面对巨人》
- 巨人下半场
- 巨人下半场
- 临洮巨人
- 巨人养成
- 进击的巨人之铠之巨人,超大型巨人
- 巨人何以成为巨人--[作者]摩罗
- 文化部要求巨人网络整改《巨人》游戏
- 旋转
- 旋转
- 旋转
- 旋转
- 旋转
- 旋转
- 巨人回来了!
- 游戏开发的哲学
- Opencv尺寸调整-resize函数
- Ubuntu14.04创建热点wifi
- Centos6.6 安装Openvpn
- 蜘蛛网属性图形控件
- 旋转吧巨人
- Activiti单元测试示例代码
- ubuntu安装搜狗输入法
- Ember.js 入门指南——handlebars遍历标签
- Opencv方框滤波-boxFilter函数
- C语言中联合体union妙用
- Ubuntu vim上下左右变ABCD问题解决方法
- 在学习Hibernate中,有关事务的总结
- Ubuntu下切换java版本