#include <cstdio>
#include <algorithm>
using namespace std;
const int MX = 1000;
int n, m;
int a[MX][MX];
int main() {
scanf("%d%d", &n, &m);
for(int i = 0; i < n; i++)
for(int j = 0; j < m; j++)
scanf("%d", &a[i][j]);
for(int i = 0; i < n/2; i++)
for(int j = 0; j < m; j++)
swap(a[i][j], a[n-i-1][m-j-1]);
if(n&1)
for(int j = 0; j < m/2; j++)
swap(a[n/2][j], a[n/2][m-j-1]);
for(int i = 0; i < n; i++) {
for(int j = 0; j < m; j++)
printf("%d ", a[i][j]);
printf("\n");
}
}
On Jul 27, 7:54 pm, Anika Jain <[email protected]> wrote:
> is it lyk for {1,2,3
> 4,5,6,
> 7,8,9}
> to be {3,2,1,
> 6,5,4,
> 9,8,7} ??
>
>
>
> On Wed, Jul 27, 2011 at 9:37 AM, Deoki Nandan <[email protected]> wrote:
> > rotate a 2D matrix by angle 180
>
> > --
> > **With Regards
> > Deoki Nandan Vishwakarma
>
> > *
> > *
>
> > --
> > You received this message because you are subscribed to the Google Groups
> > "Algorithm Geeks" group.
> > To post to this group, send email to [email protected].
> > To unsubscribe from this group, send email to
> > [email protected].
> > For more options, visit this group at
> >http://groups.google.com/group/algogeeks?hl=en.
--
You received this message because you are subscribed to the Google Groups
"Algorithm Geeks" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/algogeeks?hl=en.