回型数组
来源:互联网 发布:用数据库统计访问次数 编辑:程序博客网 时间:2024/06/02 03:56
#include<iostream>using namespace std;#define Max_Size 100//定义一个最大100*100的二维数组int arr[Max_Size][Max_Size];int main(){int n;cout << "请输入几行几列数组:";cin >> n;int i = 0, j = 0;int index = 1;while (index <= n*n){while(arr[i][j] == 0 && j < n)arr[i][j++] = index++;j--;//回退i++;//下移while(arr[i][j] == 0 && i < n)arr[i++][j] = index++;i--;//回退j--;//左移while(arr[i][j] == 0 && j >= 0)arr[i][j--] = index++;j++;//回退i--;//上移while(arr[i][j] == 0 && i >= 0)arr[i--][j] = index++;i++;//回退 如果元素不为0 向右下角移动j++;//右移 }//打印二维数组for (int i = 0; i < n; i++){for (int j = 0; j < n; j++){printf("%4d", arr[i][j]);}cout << endl;}}
阅读全文
0 0
- 回型数组
- 打印回型数组 回型矩阵 环形数组
- 打印回型数组-回型矩阵-环形数组
- Java打印回型数组
- 二维数组的回型遍历
- 泛型和数组
- 泛型与数组
- Java 泛型数组
- 泛型不支持数组
- 善用泛型数组
- Java 泛型数组
- Java 泛型数组
- 蛇型数组
- Java 泛型数组
- 泛型与数组
- 泛型数组
- 泛型数组
- 泛型与数组
- Unity 键盘,鼠标,触摸输入
- 使用@Valid @RequestBody 的用意在于抛出notvalid的异常
- Windows下Git的下载和安装配置
- tolua++入门
- Oracle中对超长内容的处理,避免出现can bind a LONG value only for insert into a LONG column错误
- 回型数组
- Springboot整合mybatis项目开发
- 提高EJB性能的十大技巧
- C++之类型转换
- Java异常处理机制
- java中字符、字符串的常用方法
- 检查字符串是否为合法的Java标识符的程序
- django 项目的html加载css文件
- unity iPhone和android手机 可读写目录