当前位置:网站首页>Select sorting and bubble sorting template
Select sorting and bubble sorting template
2022-07-04 03:38:00 【CTGU-Yoghurt】
remarks :sizeof(a)/sizeof(a[0]) The function of is to find the number of elements of the array
See this blog for more information :(1 Bar message ) About sizeof(arr)/sizeof(arr[0]) Reading (plus The detailed explanation is increased )_CTGU-Yoghurt The blog of -CSDN Blog _sizeof(arr)/sizeof(arr[0])
https://blog.csdn.net/weixin_60536621/article/details/120583464?spm=1001.2014.3001.5502
Selection sort :
void xuanzhe()
{
for (int i = 0; i < sizeof(a)/sizeof(a[0])-1; i++)
{
for (int j = i+1; j < sizeof(a)/sizeof(a[0]); j++) {
if (a[i] > a[j])
{
int t = a[i];
a[i] = a[j];
a[j] = t;
}
}
}
}Bubble sort :
void maopao()
{
for (int i = 0; i < sizeof(a) / sizeof(a[0])-1; i++)
{
for (int j = 0 ; j < sizeof(a) / sizeof(a[0])-i-1; j++) {
if (a[j] > a[j+1])
{
int t = a[j];
a[j] = a[j+1];
a[j+1] = t;
}
}
}
}Test code :
#include<iostream>
using namespace std;
int a[] = { 123,12,312,3,124,3,4534,5,423,4};
void xuanzhe()
{
for (int i = 0; i < sizeof(a)/sizeof(a[0])-1; i++)
{
for (int j = i+1; j < sizeof(a)/sizeof(a[0]); j++) {
if (a[i] > a[j])
{
int t = a[i];
a[i] = a[j];
a[j] = t;
}
}
}
}
void maopao()
{
for (int i = 0; i < sizeof(a) / sizeof(a[0])-1; i++)
{
for (int j = 0 ; j < sizeof(a) / sizeof(a[0])-i-1; j++) {
if (a[j] > a[j+1])
{
int t = a[j];
a[j] = a[j+1];
a[j+1] = t;
}
}
}
}
int main()
{
maopao();
for (int i = 0; i < sizeof(a) / sizeof(a[0]); i++)
{
cout << a[i]<<" ";
}
}边栏推荐
- 2022 registration examination for safety production management personnel of fireworks and firecracker production units and examination skills for safety production management personnel of fireworks an
- CesiumJS 2022^ 源码解读[0] - 文章目录与源码工程结构
- Katalon框架测试web(二十一)获取元素属性断言
- Setting methods, usage methods and common usage scenarios of environment variables in postman
- MySQL query
- ctf-pikachu-CSRF
- SQL statement strengthening exercise (MySQL 8.0 as an example)
- No clue about the data analysis report? After reading this introduction of smartbi, you will understand!
- Audio and video technology development weekly | 232
- Is online futures account opening safe and reliable? Which domestic futures company is better?
猜你喜欢

MySQL maxscale realizes read-write separation

What kind of experience is it when the Institute earns 20000 yuan a month!
![[PaddleSeg 源码阅读] PaddleSeg 自定义数据类](/img/88/37c535b371486db545abc392a685af.png)
[PaddleSeg 源码阅读] PaddleSeg 自定义数据类
![[source code analysis] model parallel distributed training Megatron (5) -- pipestream flush](/img/94/2bdc31ec05595dbbc8a7a8d6b22252.jpg)
[source code analysis] model parallel distributed training Megatron (5) -- pipestream flush
![[Wu Enda deep learning] beginner learning record 3 (regularization / error reduction)](/img/e9/818bdfeae766dca7d2318b52b4424d.jpg)
[Wu Enda deep learning] beginner learning record 3 (regularization / error reduction)

Package and download 10 sets of Apple CMS templates / download the source code of Apple CMS video and film website

Mindmanager2022 efficient and easy to use office mind map MindManager
![CesiumJS 2022^ 源码解读[0] - 文章目录与源码工程结构](/img/ba/c1d40de154344ccc9f2fd1dd4cb12f.png)
CesiumJS 2022^ 源码解读[0] - 文章目录与源码工程结构

ctf-pikachu-CSRF

渗透实战-SQLServer提权
随机推荐
【.NET+MQTT】.NET6 環境下實現MQTT通信,以及服務端、客戶端的雙邊消息訂閱與發布的代碼演示
Why is it recommended that technologists write blogs?
Webhook triggers Jenkins for sonar detection
Katalon框架测试web(二十一)获取元素属性断言
[PaddleSeg 源码阅读] PaddleSeg计算 mIoU
New year's first race, submit bug reward more!
@Scheduled scheduled tasks
Is online futures account opening safe and reliable? Which domestic futures company is better?
Command Execution Vulnerability - command execution - vulnerability sites - code injection - vulnerability exploitation - joint execution - bypass (spaces, keyword filtering, variable bypass) - two ex
Zlmediakit compilation and webrtc push-pull flow testing
Typical applications of minimum spanning tree
logistic regression
Rhcsa day 2
MySQL one master multiple slaves + linear replication
潘多拉 IOT 开发板学习(HAL 库)—— 实验6 独立看门狗实验(学习笔记)
Third party login initial version
[latex] production of complex tables: excel2latex and detail adjustment
数据库SQL语句汇总,持续更新......
JSON string conversion in unity
No clue about the data analysis report? After reading this introduction of smartbi, you will understand!