Renamed Files according to naming conventions

This commit is contained in:
Chetan Kaushik 2016-08-02 15:37:19 +05:30
parent cfbaec02ad
commit fb31979c03
2 changed files with 61 additions and 61 deletions

View File

@ -1,30 +1,30 @@
#include<iostream> #include<iostream>
using namespace std; using namespace std;
int main(){ int main(){
int n,k; int n,k;
cout<<"Enter size of array=\t"; cout<<"Enter size of array=\t";
cin>>n; cin>>n;
cout<<"Enter Number of indeces u want to rotate the array to left=\t"; cout<<"Enter Number of indeces u want to rotate the array to left=\t";
cin>>k; cin>>k;
int a[n];cout<<"Enter elements of array=\t"; int a[n];cout<<"Enter elements of array=\t";
for(int i=0;i<n;i++){ for(int i=0;i<n;i++){
cin>>a[i]; cin>>a[i];
} }
int temp=0; int temp=0;
for(int i=0;i<k;i++){ for(int i=0;i<k;i++){
temp=a[0]; temp=a[0];
for(int j=0;j<n;j++){ for(int j=0;j<n;j++){
if(j==n-1){ if(j==n-1){
a[n-1]=temp; a[n-1]=temp;
} }
else{ else{
a[j]=a[j+1]; a[j]=a[j+1];
} }
} }
}cout<<"Your rotated array is=\t"; }cout<<"Your rotated array is=\t";
for(int j=0;j<n;j++){ for(int j=0;j<n;j++){
cout<<a[j]<<" "; cout<<a[j]<<" ";
} }
getchar(); getchar();
return 0; return 0;
} }

View File

@ -1,31 +1,31 @@
#include <iostream> #include <iostream>
using namespace std; using namespace std;
int main(){ int main(){
int n,k; int n,k;
cout<<"Enter size of array=\t"; cout<<"Enter size of array=\t";
cin>>n; cin>>n;
cout<<"Enter Number of indices u want to rotate the array to right=\t"; cout<<"Enter Number of indices u want to rotate the array to right=\t";
cin>>k; cin>>k;
int a[n]; int a[n];
cout<<"Enter elements of array=\t"; cout<<"Enter elements of array=\t";
for(int i=0;i<n;i++) for(int i=0;i<n;i++)
cin>>a[i]; cin>>a[i];
int temp=0; int temp=0;
for(int i=0;i<k;i++){ for(int i=0;i<k;i++){
temp=a[n-1]; temp=a[n-1];
for(int j=n-1;j>=0;j--){ for(int j=n-1;j>=0;j--){
if(j==0){ if(j==0){
a[j]=temp; a[j]=temp;
} }
else{ else{
a[j]=a[j-1];} a[j]=a[j-1];}
} }
} }
cout<<"Your rotated array is=\t"; cout<<"Your rotated array is=\t";
for(int i=0;i<n;i++){ for(int i=0;i<n;i++){
cout<<a[i]<<" "; cout<<a[i]<<" ";
} }
} }