From 33e53306398bbd9d35ea20e08b4075f58ff2a377 Mon Sep 17 00:00:00 2001 From: Shashikala Date: Thu, 1 Oct 2020 14:48:40 +0530 Subject: [PATCH] added matrix rotation algorithm --- HelloWorld/helloworld.cpp | 16 ++++++++-------- algorithms/Rotate_matrixby90deg.cpp | 27 +++++++++++++++++++++++++++ 2 files changed, 35 insertions(+), 8 deletions(-) create mode 100644 algorithms/Rotate_matrixby90deg.cpp diff --git a/HelloWorld/helloworld.cpp b/HelloWorld/helloworld.cpp index b759adf..707e4f5 100644 --- a/HelloWorld/helloworld.cpp +++ b/HelloWorld/helloworld.cpp @@ -1,8 +1,8 @@ -#include -#include - -int main() -{ - printf("Hello World!"); -} - +#include +#include + +int main() +{ + printf("Hello World!"); +} + diff --git a/algorithms/Rotate_matrixby90deg.cpp b/algorithms/Rotate_matrixby90deg.cpp new file mode 100644 index 0000000..df91c90 --- /dev/null +++ b/algorithms/Rotate_matrixby90deg.cpp @@ -0,0 +1,27 @@ +//Rotate matrix by 90 degree +#include +using namespace std; +int main() +{ + int n; + cin>>n; + int i,j,matrix[n][n]; + for(int i=0;i>matrix[i][j]; + for(i=0;ii) + { + swap(matrix[k][i],matrix[k][j]); + i++; + j--; + } + } + return 0; +}