当前位置:网站首页>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]);
}边栏推荐
- PCB中常用快捷键
- JS Part 2
- The small project (servlet+jsp+mysql+el+jstl) completes a servlet with login function, with the operation of adding, deleting, modifying and querying. Realize login authentication, prevent illegal log
- Exercise 10-8 recursive implementation of sequential output of integers
- Although not necessarily the best, it must be the hardest!
- js 2023. String pair equal to the target string after connection
- 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
- FPGA test method takes mentor tool as an example
- 7-7 12-24 hour system
- Solution to failure or slow downloading of electron when electron uses electron builder to package
猜你喜欢
![[clean up the extraordinary image of Disk C]](/img/0d/331115bc5d82d6337ae975a08494b2.jpg)
[clean up the extraordinary image of Disk C]

Redis:Redis的数据结构、key的操作命令

Print. JS -- web page file printing

Scroll detection of the navigation bar enables the navigation bar to slide and fix with no content

JS Part 2

Configure stylelint

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

Redis:字符串類型數據的操作命令

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
随机推荐
Exercise 8-2 calculate the sum and difference of two numbers
Nucleic acid modified metal organic framework drug carrier | pcn-223 metal organic framework encapsulated ad adamantane | zif-8 encapsulated adriamycin (DOX)
Mysql多表查询 #子查询
全局事件总线
7-20 print 99 formula table (format output)
Fabric. JS document
concat和concat_ws()区别及group_concat()和repeat()函数的使用
7-18 finding the single root of polynomial by dichotomy
剑指 Offer 28. 对称的二叉树
Common plug-ins for vite project development
QT learning 19 standard dialog box in QT (top)
Why are grass-roots colleges and universities with "soil and poverty" called "Northeast small Tsinghua"?
JS Part 2
[clean up the extraordinary image of Disk C]
7-23 currency conversion (using array conversion)
QT learning 25 layout manager (4)
7-17 crawling worms (break exercise)
Facebook 如何将 Instagram 从 AWS 搬到自己的服务器
js . Find the first palindrome string in the array
Metal organic framework (MOFs) antitumor drug carrier | pcn-223 loaded with metronidazole | uio-66 loaded with ciprofloxacin hydrochloride(