当前位置:网站首页>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]);
}边栏推荐
- Current situation, analysis and prediction of information and innovation industry
- Fabric. JS document
- Exercise 8-8 moving letters
- Simulated access
- SSH访问控制,多次失败登录即封掉IP,防止暴力破解
- Polestar美股上市:5.5万台交付如何支持得起超200亿美元估值
- Why are grass-roots colleges and universities with "soil and poverty" called "Northeast small Tsinghua"?
- x86汇编语言-从实模式到保护模式 笔记
- js . Find the first palindrome string in the array
- Global event bus
猜你喜欢

x86汇编语言-从实模式到保护模式 笔记

Similarities and differences between Allegro, OrCAD, net alias, port, off page connector and how to select them

Leetcode(4)——尋找兩個正序數組的中比特數

Redis: redis data structure and key operation commands

QT learning 20 standard dialog box in QT (middle)

QT learning 17 dialog box and its types

Exercise 10-2 recursive factorial sum

JS Part III

Concat and concat_ Ws() differences and groups_ Use of concat() and repeat() functions

Redis:字符串类型数据的操作命令
随机推荐
玖逸云黑免费无加密版本源码
QT learning 17 dialog box and its types
超简单手机地图开发
7-16 find the set of integers that meet the given conditions
How to bold text in AI
Leetcode (4) - - trouver la médiane de deux tableaux ordonnés positifs
28: Chapter 3: develop Passport Service: 11: define attributes in the configuration file, and then obtain them in the code;
JS shift operators (< <,> > and > > >)
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
7-17 crawling worms (break exercise)
Jiuyi cloud black free encryption free version source code
JVM object lifecycle
Facebook 如何将 Instagram 从 AWS 搬到自己的服务器
Exercise 6-2 using functions to sum special A-string sequences
concat和concat_ws()区别及group_concat()和repeat()函数的使用
别再问自己适不适合做软件测试了
Global event bus
关于回溯问题中的排列问题的思考(LeetCode46题与47题)
剑指 Offer 28. 对称的二叉树
必贝特医药冲刺科创板:年营收97万亏损1.37亿 拟募资20亿