Quick actions

cmd+k|ctrl+k

Navigation

Languages

Rotate a Matrix anticlockwise 90 degree

Snippet info

Language

Cpp

Visibility

public

Author

singhrishabh557

Created

2019-02-06T16:23:22Z

Updated

2019-02-06T16:23:22Z

#include <iostream>
using namespace std;

int main() {
      int a[3][3] ={1,2,3,4,5,6,7,8,9};
    
        int temp[3][3];
         for(int i=0;i<3;i++)
          for(int j=0;j<3;j++)
                 temp[i][j]=a[j][2-i];
                 
           for(int i=0;i<3;i++)
          {  cout<<"\n";
              for(int j=0;j<3;j++)
                cout<<temp[i][j]<<"\t";
       
          }
          
    return 0;
}
INFO