FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
cpp-algorithms/sorting/BubbleSort.cpp at master · atwill007/cpp-algorithms · GitHub
atwill007
/
cpp-algorithms
Public
Notifications
You must be signed in to change notification settings
Fork
1
Star
2
Code
Issues
0
Pull requests
0
Actions
Projects
Security and quality
0
Insights
Additional navigation options
Code
Issues
Pull requests
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
cpp-algorithms
/
sorting
/
BubbleSort.cpp
Copy path
More file actions
More file actions
Latest commit
History
History
History
29 lines (24 loc) · 595 Bytes
Breadcrumbs
cpp-algorithms
/
sorting
/
BubbleSort.cpp
Copy path
File metadata and controls
29 lines (24 loc) · 595 Bytes
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
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
#
include
<
iostream
>
#
include
<
vector
>
//
👇用到了向量
#
include
<
algorithm
>
//
👇用到了ostream_iterator
#
include
"
./lib/DoubleVector.h
"
//
自定义Double型向量输入输出工具头文件
using
namespace
std
;
/*
*
* 冒泡法排序
*/
int
main
()
{
vector<
double
> vList =
cinDoubleVector
();
int
len = vList.
size
();
//
冒泡排序逻辑
for
(
int
i =
0
; i < len; i++)
{
for
(
int
j =
0
; j < len -
1
- i; j++)
{
if
(vList[j] > vList[j +
1
])
swap
(vList[j], vList[j +
1
]);
}
}
coutDoubleVector
(vList);
return
0
;
}
Back
|
FazBrowse Home
|
New Git URL