Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
Rotate90
//g++ 7.4.0 //rotate 90 //this code is created by Rezaul Hoque on August 02,2021;contact: jewelmrh@yahoo.com //note: codes shared by Rezaul Hoque on rextester are not for sale; they are created and shared to facilitate the algorithm learning process; many like Hoque use this platform to practice programming ;Rezaul hopes his contribution helps others to fine tune their learning; #include <iostream> using namespace std; const int n=3; void rotate(int [][3],const int); void read(int [][3]); void read(int a[3][3]){ cout<<"Enter 9 integers,3 per row:\n"; for(int i=0;i<3;i++){ for(int j=0;j<3;j++) cin>>a[i][j]; } cout<<"Initial matrix:\n"; for(int i=0;i<3;i++){ cout<<"\n"; for(int j=0;j<3;j++) cout<<" "<<a[i][j]; } } void rotate(int m[][3],const int n){ int temp[n][n]; int i,j,t=0; for(i=n-1;i>=0;--i){ for(j=0;j<n;j++) temp[j][t]= m[i][j]; ++t; } for(int i=0;i<3;i++){ cout<<"\n"; for(int j=0;j<3;j++) cout<<" "<<temp[i][j]; } } int main() { int a[3][3]; read(a); cout<<"\nAfter 90° rotation:\n"; rotate(a,n); return 0; }
run
|
edit
|
history
|
help
0
TempSpecial
Hello world.c
OperatorOverload
dijkstra's algo
Sliding Game
ugly quick sort
kadane's algorithm
СП КИ ЭТАП 2
Search in a rotated sorted array two methods
SVGAnimated Value