# LeetCode - 0832. Flipping an Image ### 題目網址:https://leetcode.com/problems/flipping-an-image/ ###### tags: `LeetCode` `Easy` `陣列` `模擬` ```cpp= /* -LeetCode format- Problem: 832. Flipping an Image Difficulty: Easy by Inversionpeter */ class Solution { public: vector<vector<int>> flipAndInvertImage(vector<vector<int>>& A) { int width = A[0].size(), half = width >> 1; for (int i = 0; i != A.size(); ++i) { for (int j = 0; j < half; ++j) { A[i][j] = !A[i][j]; A[i][width - j - 1] = !A[i][width - j - 1]; swap(A[i][j], A[i][width - j - 1]); } if (width & 1) A[i][half] = !A[i][half]; } return A; } }; ```