001-algorithm-print matrix on the clockwise
来源:互联网 发布:java ftpclient sftp 编辑:程序博客网 时间:2024/06/09 01:57
1 2 3
4 5 6 ---> 1 2 3 6 9 8 7 4 5
7 8 9
void print_matrix(int a[], int m, int n){//matrix a with size m nstd::vector<int> x;int point1 = 0;int point2 = n - 1;int point3 = m*n - 1;int point4 = m*n - n;while (point1<=point2 && point2<=point3 && point3>=point4 && point4>=point1){for (int i = point1; i < point2; i++){x.push_back(a[i]);}for (int i = point2; i < point3; i += n){x.push_back(a[i]);}for (int i = point3; i > point4; i--){x.push_back(a[i]);}for (int i = point4; i > point1; i -= n){x.push_back(a[i]);}if (point1 == point2 && point3 == point4 && point1==point3){x.push_back(a[point1]);}point1 += (n + 1);point2 += (n - 1);point3 -= (n + 1);point4 -= (n - 1);}//whilefor (auto i : x){std::cout << i << " ";}}
1 0
- 001-algorithm-print matrix on the clockwise
- clockwise print binary search tree
- The Algorithm on Combinations
- [Google] print the outline of a complete binary tree in anti-clockwise direction
- The ``Clockwise/Spiral Rule''
- The Clockwise/Spiral Rule
- print numbers on the screen.(show_str and dtoc function)
- cat - concatenate files and print on the standard output
- Print Matrix Diagonally
- EM算法笔记(a note on the EM algorithm)
- Cameras on OpenGL ES 2.x - The ModelViewProjection Matrix
- Cameras on OpenGL ES 2.x - The ModelViewProjection Matrix
- Clockwise/Anti-clockwise
- [神经网络]2.1-How the backpropagation algorithm works-Warm up: a fast matrix-based approach ...(翻译)
- [Algorithm]九章九之一:Matrix DP
- Unable to print reports as PDF files on the server using batch processing AX
- 每日一命令(10)cat (concatenate files and print on the standard output)
- Algorithm: Print table of 500 primes
- 【学习笔记】CSS的基本语法(二)
- 关于KCF的几个问题个人理解
- CSS3中box-shadow属性的使用方法
- 合并两个排序的链表
- 分治法之二分查找
- 001-algorithm-print matrix on the clockwise
- 11持有对象-Java编程思想
- C++虚函数的认识
- Python返回函数_函数闭包_lambda匿名函数
- Android开发规范——命名 (转)
- 关于static 的使用
- Java多线程 -- JUC包源码分析2 -- Copy On Write/CopyOnWriteArrayList/CopyOnWriteArraySet
- 显卡性能指标参数概念解释
- Unity3D-实现水面渲染