#include <iostream>
using namespace std;
const int M = 3;	//行数 
const int N = 5;	//列数 
int main() 
{
	int a[M][N] = {{1,2,3,4,5},{6,7,8,9,10},{11,12,13,14,15}};
	int *p = a[0];
	
	//正常输出矩阵 
	for(int i=0;i<M;i++)
	{
		for(int j=0;j<N;j++)
		{
			cout<<a[i][j]<<" ";
		}
		cout<<endl;
	}
	cout<<endl;
	
	//右旋
	cout<<"右旋矩阵:"<<endl; 
	for(int i=0;i<N;i++)
	{
		for(int j=M-1;j>=0;j--)
		{ 
			cout<< *(p+j*N+i)<<" ";
		}
		cout<<endl;
	}
	
	//左旋
	cout<<endl;
	cout<<"左旋矩阵:"<<endl; 
	for(int i=N-1;i>=0;i--)
	{
		for(int j=0;j<M;j++)
		{ 
			cout<< *(p+i+j*N)<<" ";
		}
		cout<<endl;
	} 
	return 0;
}原文地址:http://blog.csdn.net/huolang_vip/article/details/45587155