Image rotation

Given an image represented by an NxN matrix, where each piexel in the image is 4 bytes, write a method to rotate the image by 90 degrees. Can you do this in place?

C++:
01 void matrixRotation(vector<int*>& M,int size, int start, int end)
02 {
03     if(start>=end)
04         return;
05     for(int i=0;i<endstart;i++){
06         int tmp=M[start][start+i];
07         M[start][start+i]=M[endi][start];
08         M[endi][start]=M[end][endi];
09         M[end][endi]=M[start+i][end];
10         M[start+i][end]=tmp;
11     }
12     matrixRotation(M,size,start+1,end1);
13 }
Advertisements
This entry was posted in Array and linked list, Recursive. Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s