当前位置:网站首页>C language: bubble sort
C language: bubble sort
2022-06-25 08:45:00 【zbossz】
#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#define N 10
void Bubble_Sort(int* a,int i,int j,int t)
{
for (i = 0;i < N - 1;i++)
{
for (j = 0;j < N - i - 1;j++)
{
if (a[j] > a[j + 1])
{
t = a[j];
a[j] = a[j + 1];
a[j + 1] = t;
}
}
}
}
int main()
{
int i=0, j=0, t=0, a[N];
printf(" Please enter %d It's an integer :",N);
for (i = 0;i < N;i++)
scanf("%d", &a[i]);
Bubble_Sort(a,i,j,t);
for (i = 0;i < N;i++)
printf("%d ", a[i]);
printf("\n");
return 0;
}
flag In order to reduce the number of cycles of the constant sequence , To maximize efficiency .
such as 1111111111 This sequence , Just go in 10 Secondary cycle .
If not flag, I'll go in 100 Secondary cycle . The efficiency is greatly reduced .
边栏推荐
- 声纹技术(六):声纹技术的其他应用
- UEFI:修复 EFI/GPT Bootloader
- Is there no risk in the security of new bonds
- 通过客户经理的开户二维码开股票账户安全吗?还是去证券公司开户安全?
- Sharepoint:sharepoint server 2013 and adrms Integration Guide
- 各种同步学习笔记
- [reinforcement learning notes] common symbols in reinforcement learning
- OpenFOAM:底层
- SharePoint:SharePoint 2013 with SP1 简易安装
- QSS 不同风格的按钮
猜你喜欢

Unity Addressable批量管理

Exchange:管理日历权限

在二叉树(搜索树)中找到两个节点的最近公共祖先(剑指offer)

2021 "Ai China" selection

How is the ISM model analyzed?

EasyPlayer流媒体播放器播放HLS视频,起播速度慢的技术优化

Incluxdb time series database

Index analysis of DEMATEL model

Easyplayer streaming media player plays HLS video. Technical optimization of slow starting speed

How to calculate the information entropy and utility value of entropy method?
随机推荐
GPU calculation
声纹技术(四):声纹识别的工程部署
C language "Recursion Series": recursively realizing the n-th power of X
Go language learning tutorial (13)
微信小程序_7,项目练习,本地生活
声纹技术(五):声纹分割聚类技术
Getting to know the generation confrontation network (11) -- using pytoch to build wgan to generate handwritten digits
linux中的mysql有10061错误怎么解决
SharePoint:SharePoint Server 2013 与 ADRMS 集成指南
【总结】1361- package.json 与 package-lock.json 的关系
Getting to know the generation confrontation network (12) -- using pytoch to build wgan-gp to generate handwritten digits
What is the file that tp6 automatically executes? What does the tp6 core class library do?
现在网上开通股票账号安全吗?
atguigu----17-生命周期
NIPS 2014 | Two-Stream Convolutional Networks for Action Recognition in Videos 阅读笔记
进击的技术er,遇见实习岗位信息
Is it safe to open an account online? Xiaobai asks for guidance
¥3000 | 录「TBtools」视频,交个朋友&拿现金奖!
如何实现一个系统调用
Word2vec, phrases, phraser, keyedvectors commonly used in gensim