LeetCode初级算法-数组-11
2019-01-31 19:37
197 查看
题目:旋转图像
C语言解题
void rotate(int** matrix, int matrixRowSize, int *matrixColSizes) { int temp; for (int i = 0; i < matrixRowSize; i++) { for (int j = i; j < *matrixColSizes; j++) { temp = matrix[i][j]; matrix[i][j] = matrix[j][i]; matrix[j][i] = temp; } } for (int i = 0; i < *matrixColSizes; i++) { for (int j = 0; j < matrixRowSize/2; j++) { temp = matrix[i][j]; matrix[i][j] = matrix[i][matrixRowSize - j - 1]; matrix[i][matrixRowSize - j - 1] = temp; } } }
将矩阵转置,再将每一行逆序。
相关文章推荐
- leetcode初级算法数组11 旋转图像
- leetcode 初级算法数组7加一
- LeetCode(初级算法)数组篇--两个数组的交集II c++
- LeetCode-探索-初级算法-数组-从排序数组中删除重复项-java
- leetcode 初级算法数组8 移动0
- LeetCode(初级算法)数组篇--从排序数组中删除重复项c++
- LeetCode(初级算法)数组篇--买卖股票的最佳时机 II c++
- LeetCode(初级算法)数组篇--旋转数组c++
- Leetcode初级算法6两个数组的交集
- LeetCode初级算法-数组-旋转数组(python)
- LeetCode(初级算法)数组篇-移动零
- LeetCode初级算法数组9 两数之和
- LeetCode(初级算法)数组篇--加一c++
- LeetCode(初级算法)数组篇--存在重复c++
- LeetCode探索模块初级算法数组章节python3代码实现
- LeetCode(初级算法)数组篇--只出现一次的数字c++
- [leetcode]初级算法——树
- leetcode:Remove Duplicates from Sorted Array(去掉数组重复数字,常数空间限制)【面试算法题】
- 算法系列(11)LeetCode136 Single Number
- 初级算法-数组-从排序数组中删除重复项