这个有点像DSP FPGA Chang Choo的题目,一般是放大插值,DFT,IIR之类的Verilog题目。
题目在这:Given an image represented by an NxN matrix, where each pixel in the image is 4 bytes, write a method to rotate the image by 90 degrees. Can you do this in place?
//https://github.com/monish001/CPP-Programs/blob/master/CTCI/1.6MatrixRotateBy90.cpp
//MatrixRotate90.cpp
#include
using namespace std;
void swap(char &a, char &b){
char t = a;
a = b;
b = t;
}
void rotate(char** a, int n){
for (int i=0; i
注意,这里的循环基和index需要留心注意。
关于index的选择,可以参考这个草图: