当前位置:网站首页>Relearn bubble sort
Relearn bubble sort
2022-08-10 09:20:00 【dudu-03】
Bubble sort is an algorithm that we have learned when we started learning programming. Today, we will rewrite the algorithm we have learned before.
index is the end of our next loop.
#includeusing namespace std;void so(int a[]){int index = 10;int j;int co = 1;bool flag = true;for(int i = 0; i < 10; i++) cin >> a[i];while(flag){j = -1;for(int i = 0; i < index; i++){if(a[i] > a[i + 1]) {swap(a[i],a[i + 1]);j = i + 1;cout << "No." << co++ << "Order: ";for(int i = 0; i < 10; i++) cout << a[i] << " " ;puts("");}if(i == index - 1) index = j;}if(j == -1){flag = !flag;cout << "Sort done";}}}int main(){int a[100];so(a);return 0;} 边栏推荐
猜你喜欢

【API Management】What is API Management and why is it important?

Spotify expresses its architectural design using the C4 model

FPGA时钟篇(二) 7系列clock region详解

PTA Exercise 2.2 Rotate an Array Left
![[Metaverse Omi Says] See how UCOUCO integrates performance art into the Metaverse](/img/2e/75e52bb202ae260daf23f44fa0d3e6.png)
[Metaverse Omi Says] See how UCOUCO integrates performance art into the Metaverse

FPGA中BEL Site Tile FSR SLR分别指什么?

How AliExpress sellers seize product search weight

J9 Digital Theory: What kind of sparks will Web3.0+ Internet e-commerce cause?

【API架构】REST API 行业辩论:OData vs GraphQL vs ORDS

MUDA:对齐特定域的分布和分类器以实现来自多源域的跨域分类
随机推荐
Pieces of TensorFlow 2.9 (1)
Linux下载安装MySql
线程池的基本概念、结构、类
Flink部署 完整使用 (第三章)
2022-08-09:以下go语言代码输出什么?A:否,会 panic;B:是,能正确运行;C:不清楚,看投票结果。
【API架构】REST API 行业辩论:OData vs GraphQL vs ORDS
DAY25:逻辑漏洞复现
并查集学习
关于镜像源的一些记录
It is obvious that a unique index is added, why does it still generate duplicate data?
The implementation of the seemingly useless component (text gradient) in NaiveUI is so simple
【微信小程序】一文读懂页面导航
mysql千万级别数据库优化
Spotify使用C4模型表达其架构设计
幂次方(暑假每日一题 20)
shell------常用小工具,sort,uniq,tr,cut
iwemeta metaverse: Ali's first COO: how to build a sales force
shell遍历文件夹并输出
ARM结构体系3:ARM指令的寻址和异常中断处理
[Metaverse Omi Says] Listen to how Rabbit Fan Rabbit creates a new era of trendy play from virtual to reality