dadafak
Patch Maker
LEVEL 1
200 XP
Selection Sort in C++. By this method, you can easily sort a for loop code and array. Below are the sample codes:
Note: Due to the size or complexity of this submission, the author has submitted it as a .zip file to shorten your download time. After downloading it, you will need a program like Winzip to decompress it.
Virus note: All files are scanned once-a-day by SourceCodester.com for viruses, but new viruses come out every day, so no prevention program can catch 100% of them.
FOR YOUR OWN SAFETY, PLEASE:
1. Re-scan downloaded files using your personal virus checker before using it.
2. NEVER, EVER run compiled files (.exe's, .ocx's, .dll's etc.)--only run source code.
Download
- #include<iostream>
- #include<conio.h>
- using namespace std;
- int
main(
)
- {
- int
arraylength,
num[
1000
]
,
num1,
d,
num2=
0
;
- cout<<
"Enter the total no. of element: "
;
- cin>>
arraylength;
- for
(
int
i=
0
;
i<
arraylength;
i++
)
- {
cout<<
"Enter No."
<<
i+
1
<<
": "
;
- cin>>
num[
i]
,
num[
d]
;
}
- {
cout<<
" \n
"
<<
endl;
}
- for
(
int
d=
0
;
d<
arraylength;
d++
)
{
- cout<<
num[
d]
<<
" "
<<
"\n
"
<<
endl;
- cout<<
"UNSORTED ARRAY : "
;
- for
(
int
i =
0
;
i<
arraylength;
i++
)
{
- cout<<
num[
i]
<<
" "
;
- }
- cout<<
endl<<
"SORTED ARRAY : "
;
- for
(
int
a=
0
;
a<
arraylength-
1
;
a++
)
{
- for
(
int
b=
0
;
b<
arraylength-
a-
1
;
b++
)
{
- if
(
num[
b]
<
num[
b+
1
]
)
{
- num1=
num[
b]
;
- num[
b]
=
num[
b+
1
]
;
- num[
b+
1
]
=
num1;
- }
- }
- }
- for
(
int
r=
0
;
r<
arraylength;
r++
)
{
- cout<<
num[
r]
<<
" "
;
- }
- }
- getch
(
)
;
- return
0
;
- }
Note: Due to the size or complexity of this submission, the author has submitted it as a .zip file to shorten your download time. After downloading it, you will need a program like Winzip to decompress it.
Virus note: All files are scanned once-a-day by SourceCodester.com for viruses, but new viruses come out every day, so no prevention program can catch 100% of them.
FOR YOUR OWN SAFETY, PLEASE:
1. Re-scan downloaded files using your personal virus checker before using it.
2. NEVER, EVER run compiled files (.exe's, .ocx's, .dll's etc.)--only run source code.
Download
You must upgrade your account or reply in the thread to view the hidden content.