Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
1
170050084-170050092-170050102-git
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
SABBITHI NAREN RAHUL
170050084-170050092-170050102-git
Commits
7af41a1c
Commit
7af41a1c
authored
Aug 26, 2018
by
ATLA THARUN TEJA
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
change implementation to insertion-sort
parent
6b3ddc6b
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
42 additions
and
14 deletions
+42
-14
sorting.cpp
sorting.cpp
+42
-14
No files found.
sorting.cpp
View file @
7af41a1c
...
...
@@ -4,20 +4,48 @@
using
namespace
std
;
vector
<
int
>
sort_custom
(
vector
<
int
>
c
){
bool
pass
=
false
;
//have we passed through the cay without a swap?
int
temp
;
while
(
!
pass
){
pass
=
true
;
for
(
int
i
=
0
;
i
<
c
.
size
()
-
1
;
i
++
){
if
(
c
[
i
]
>
c
[
i
+
1
]){
pass
=
false
;
temp
=
c
[
i
];
c
[
i
]
=
c
[
i
+
1
];
c
[
i
+
1
]
=
temp
;
}
unsigned
int
i
,
j
;
vector
<
int
>
sortedArray
(
c
.
size
());
sortedArray
=
c
;
int
max
;
for
(
i
=
0
;
i
<
c
.
size
();
i
++
){
for
(
j
=
i
;
j
<
c
.
size
();
j
++
){
if
(
sortedArray
[
i
]
<
sortedArray
[
j
]){
int
tmp
;
tmp
=
sortedArray
[
i
];
sortedArray
[
i
]
=
sortedArray
[
j
];
sortedArray
[
j
]
=
tmp
;
}
}
}
}
return
c
;
return
sortedArray
;
}
int
main
()
{
srand
(
time
(
NULL
));
int
n
;
unsigned
int
i
;
vector
<
int
>
nums
;
cin
>>
n
;
for
(
i
=
1
;
i
<=
n
;
i
++
){
int
element
;
cin
>>
element
;
nums
.
push_back
(
element
);
}
vector
<
int
>
sortedNums
=
sort_custom
(
nums
);
for
(
i
=
0
;
i
<
sortedNums
.
size
();
i
++
){
cout
<<
sortedNums
[
sortedNums
.
size
()
-
i
-
1
]
<<
" "
;
}
return
0
;
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment