当前位置:网站首页>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 .
边栏推荐
- 进击的技术er,遇见实习岗位信息
- 4 reasons for adopting "safe left shift"
- Find the nearest common ancestor (Sword finger offer) of two nodes in the binary tree (search tree)
- Getting to know the generation confrontation network (11) -- using pytoch to build wgan to generate handwritten digits
- How to calculate the information entropy and utility value of entropy method?
- OpenFOAM:底层
- openid是什么意思?token是什么意思?
- Scanpy(七)基于scanorama整合scRNA-seq实现空间数据分析
- Stimulsoft Ultimate呈现报告和仪表板
- How to solve the 10061 error of MySQL in Linux
猜你喜欢

Incluxdb time series database

How to increase the monthly salary of software testing from 10K to 30K? Only automated testing can do it

Data preprocessing: discrete feature coding method

如何设计测试用例

Day 5 script and UI System

What are the indicators of DEA?

Find the nearest common ancestor (Sword finger offer) of two nodes in the binary tree (search tree)

城链科技平台,正在实现真正意义上的价值互联网重构!

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

Super simple case: how to do hierarchical chi square test?
随机推荐
[operation tutorial] how does the tsingsee Qingxi video platform import the old database into the new database?
声纹技术(五):声纹分割聚类技术
A 35 year old Tencent employee was laid off and sighed: a suite in Beijing, with a deposit of more than 7 million, was anxious about unemployment
如何实现一个系统调用
Discrimination of configuration, software configuration items and software configuration management items
Data preprocessing: discrete feature coding method
OpenFOAM:底层
How to become a software testing expert? From 3K to 17k a month, what have I done?
How to design test cases
2021 "Ai China" selection
声纹技术(四):声纹识别的工程部署
Problems caused by Gil problems and Solutions
第五天 脚本与UI系统
进击的技术er,遇见实习岗位信息
106. 简易聊天室9:使用 Socket 传递音频
atguigu----17-生命周期
故障:Outlook 收发邮件时的 0x800CCC1A 错误
初识生成对抗网络(12)——利用Pytorch搭建WGAN-GP生成手写数字
[summary] 1361- package JSON and package lock JSON relationship
软件测试月薪10K如何涨到30K,只有自动化测试能做到