当前位置:网站首页>Sort ten integers using selection
Sort ten integers using selection
2022-06-22 05:07:00 【Jiangxueqian】
Use an array to hold a set of numbers .
The so-called selective method , It's about putting 10 The smallest of the numbers is the same as a[0] In exchange for , then a[1]~a[9] The smallest number and number in a[1] In exchange for , And so on .
Every round of comparison , Find the smallest unordered number , A total comparison 9 round .
#include <stdio.h>
void sort(int a[])
{
int temp;
for (int i = 0; i < 10; i++)
{
for (int j = i+1; j < 10; j++)
{
if (a[j] < a[i])
{
temp = a[i];
a[i] = a[j];
a[j] = temp;
}
}
}
}
int main()
{
int a[10];
for (int i = 0; i < 10; i++)
{
scanf("%d", &a[i]);
}
sort(a);
for (int j = 0; j < 10; j++)
{
printf("%-3d", a[j]);
}
return 0;
}test result :
![]()
边栏推荐
- NHibernate method for viewing generated SQL statements
- yarn部署模式依赖预上传设置
- IQueryable和IEnumerable的区别
- Web page design and production final assignment report - College Students' online flower shop
- Monorepo silk slide methodology: reference module hot update
- The Impossible Triangle of NLP?
- Postman document parameterization
- Progress warning and problem management of progress control in Zhiyuan project management SPM system
- Software architecture and pattern: structure, component and relationship
- 花式优化器整理
猜你喜欢
![Reading notes on how MySQL works [updating]](/img/4a/56cff3db0d45e66f51beb490c3ae71.jpg)
Reading notes on how MySQL works [updating]
Solve the shortage of developers. Maybe it can help you

【chrome】 谷歌小技巧 谷歌浏览器 自带 滚动截图(全屏截图)

10 "no no no" redis interview questions

在Vs Code中搭建JSP开发环境
Please, use three JS make 2D pictures have 3D effect cool, OK

Solutions to MySQL 8.0 public key retrieval is not allowed errors

Database - basic knowledge

C语言变量的存储方式和生存期
![[fault diagnosis] CUDA kernel errors might be asynchronously reported at some other API call, so the stacktrace B](/img/f3/86bc79d7b2fb0a7f5ab77d5bbbeb18.png)
[fault diagnosis] CUDA kernel errors might be asynchronously reported at some other API call, so the stacktrace B
随机推荐
Software architecture and pattern: structure, component and relationship
Recruiters - issue 23
JUC - thread interrupt and thread waiting and wakeup (locksupport)
php正则怎么去掉括号内容
Database - basic knowledge
Monorepo絲滑方法論:引用模塊熱更新
7. Gateway global filter
Fancy optimizer finishing
Detailed explanation of deep learning technology for building an image search engine that can find similar images
The application of RPC technology and its framework sekiro in crawler reverse, encrypting data is a shuttle!
Target detection algorithm based on deep learning interview essential (rcnn~yolov5)
zipimport.ZipImportError:
Remote Dictionary Server(Redis)——基于 KV 结构的作为 Cache 使用的 NoSQL 数据库管理系统
【使用指南】使用公共的conda创建环境
[details] domestic website filing process and steps
uwsgi-invalid-request-block-size invalid request block size: 21327 (max 4096)... Skip solution
Exness: ECB president Christine Lagarde reiterated her plan to raise interest rates at the July meeting
Web page design and production final assignment report - College Students' online flower shop
8. Gateway request logging
Tupu software 2D and 2.5D case collection | smart Park, data center, SMT production line