Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add files via upload #6128

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
26 changes: 26 additions & 0 deletions code/sorting/src/AnandSort.cpp
@@ -0,0 +1,26 @@
/* This Sorting Algorith is based on array index matching, if element matches with the index number then that element is assigned at that place or index of array */
/* if we will assign each element at unique index and then print array in increasing order, ofcorse element will be printed in ascending order */
#include<iostream>
using namespace std;
int main(){
int i,j,n,A[100]={0}; // Initally each index is assigned with 0
cout<<"Enter Size Of the Array: ";
cin>>n;
int B[n];
cout<<"Enter elements: ";
for(i=0;i<n;i++){
cin>>B[i]; }
for(i=0;i<n;i++){
for(j=0;j<=100;j++){
if(B[i]==j){
A[j]=B[i];
break;
}
}
}
for(i=0;i<100;i++){
if(A[i]!=0){ //It will print only that index element value which is not having 0
cout<<A[i]<<" "; }
}
return 0;
}