当前位置:网站首页>Selective sorting
Selective sorting
2022-07-03 14:15:00 【Study hard 867】
This question requires that you give n An integer is sorted from large to small and then output .
Input format :
The first line of input gives no more than one 10 The positive integer n. The second line gives n It's an integer , Separated by spaces .
Output format :
Output a sequence of numbers from large to small in a row , There is a space between adjacent numbers , There must be no extra space at the end of the line .
sample input :
4
5 1 7 6
sample output :
7 6 5 1Code :
#include <stdio.h>
int main(){
int a[10];
int n;
int i,j,max;
scanf("%d",&n);
for(i=0;i<n;i++){
scanf("%d",&a[i]);
}
max=a[0];
for(i=0;i<n;i++){
for(j=i+1;j<n;j++){
if(a[i]<a[j]){
max=a[i];
a[i]=a[j];
a[j]=max;
}
}
}
for(i=0;i<n-1;i++)printf("%d ",a[i]);
printf("%d",a[n-1]);
}边栏推荐
- JS new challenges
- 添加Zabbix计算类型项目Calculated items
- Understanding of closures
- Too many files with unapproved license
- simpleParallax. JS (create poor visual effects for website pictures)
- 好看、好用、强大的手写笔记软件综合评测:Notability、GoodNotes、MarginNote、随手写、Notes Writers、CollaNote、CollaNote、Prodrafts、Noteshelf、FlowUs、OneNote、苹果备忘录
- Folic acid modified metal organic framework (zif-8) baicalin loaded metal organic framework composite magnetic material (AU- [email
- Print. JS -- web page file printing
- JVM class loading
- 八大排序
猜你喜欢

Jiuyi cloud black free encryption free version source code

jvm-类加载

一文了解微分段应用场景与实现机制

allegro,orcad, net alias,port,off-page connector之间的异同点和如何选取

中感微冲刺科创板:年营收2.4亿净亏1782万 拟募资6亿

QT learning 17 dialog box and its types

jvm-对象生命周期

7-7 12-24 hour system

Polestar美股上市:5.5万台交付如何支持得起超200亿美元估值

Exercise 8-7 string sorting
随机推荐
7-8 overspeed judgment
Leetcode (4) - - trouver la médiane de deux tableaux ordonnés positifs
Redis: commandes d'action pour les données de type chaîne
JS Part III
Scroll detection, so that the content in the lower right corner is not displayed at the top of the page, but is displayed as the mouse slides
QT learning 24 layout manager (III)
全局事件总线
Fabric. JS document
Thinking about the arrangement problem in the backtracking problem (leetcode questions 46 and 47)
Redis:字符串类型数据的操作命令
JS new challenges
Zabbix添加Calculated items后保存页面成空白
28:第三章:开发通行证服务:11:在配置文件中定义属性,然后在代码中去获取;
Concat and concat_ Ws() differences and groups_ Use of concat() and repeat() functions
小项目(servelt+jsp+mysql+EL+JSTL)完成一个登录功能的Servlet,具有增删改查的操作。实现登录身份验证,防止非法登录,防止多点登录,记住用户名密码功能。
Similarities and differences between Allegro, OrCAD, net alias, port, off page connector and how to select them
Exercise 6-6 use a function to output an integer in reverse order
Solution to failure or slow downloading of electron when electron uses electron builder to package
Redis: operation command of string type data
玖逸云黑免费无加密版本源码