-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathmy_sort.cpp
More file actions
62 lines (46 loc) · 1.03 KB
/
my_sort.cpp
File metadata and controls
62 lines (46 loc) · 1.03 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
#include<stdio.h>
#include<iostream>
#include<stdlib.h>
using namespace std;
void my_sort(int n, int org[], int copy[]){
int smallest=0,i,j,k;
for(j=0;j<n;j++){
i=0, smallest = org[0];
while(org[i]!='\0'){
if(org[i]<smallest){
smallest = org[i];
}
i++;
}
i=0;
while(org[i]!='\0'){
if(org[i] == smallest){
k = i;
while(org[k+1]!='\0'){
org[k] = org[k+1];
k++;
}
org[k+1]='\0';
}
i++;
}
copy[j] = smallest;
}
}
int main(){
cout<<"Input the Size : ";
int n,i;
cin>>n;
int ary[n];
//make an empty array for my sort
int ary1[n];
cout<<"Input the Numbers\n";
for(i=0;i<n;i++){
cout<<"Element "<<(i+1)<<" : ";
cin>>ary[i];
}
my_sort(n,ary,ary1);
for(i=0;i<n;i++){
cout<<ary1[i]<<"\n";
}
}