当前位置:网站首页>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 1
Code :
#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]);
}
边栏推荐
- QT learning 24 layout manager (III)
- QT learning 20 standard dialog box in QT (middle)
- 中国锂电池电解液行业市场专项调研报告(2022版)
- Toast UI editor (editor allows you to edit your markup document using text or WYSIWYG, with syntax highlighting, scrolling synchronization, real-time preview and chart functions.)
- 7-9 find a small ball with a balance
- JS continues to explore...
- Exercise 9-3 plane vector addition
- QT learning 25 layout manager (4)
- Metal organic framework material zif-8 containing curcumin( [email protected] Nanoparticles) | nano metal organic framework carry
- Leetcode(4)——尋找兩個正序數組的中比特數
猜你喜欢
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
关于回溯问题中的排列问题的思考(LeetCode46题与47题)
剑指 Offer 28. 对称的二叉树
QT learning 20 standard dialog box in QT (middle)
[email"/>
Folic acid modified metal organic framework (zif-8) baicalin loaded metal organic framework composite magnetic material (AU- [email
QT learning 22 layout manager (I)
Understanding of closures
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
Why are grass-roots colleges and universities with "soil and poverty" called "Northeast small Tsinghua"?
JS matrix zero
随机推荐
7-24 reduction of the simplest fraction (rolling Division)
Metal organic framework (MOFs) antitumor drug carrier | pcn-223 loaded with metronidazole | uio-66 loaded with ciprofloxacin hydrochloride(
7-17 crawling worms (break exercise)
中国PETG市场预测及战略研究报告(2022版)
中国锂电池电解液行业市场专项调研报告(2022版)
牛客网:过河卒
Exercise 9-1 time conversion
7-18 finding the single root of polynomial by dichotomy
Webpage connection database ~ simple implementation of addition, deletion, modification and query complete code
Leetcode(4)——尋找兩個正序數組的中比特數
Nucleic acid modified metal organic framework drug carrier | pcn-223 metal organic framework encapsulated ad adamantane | zif-8 encapsulated adriamycin (DOX)
LNMP环境mail函数不能发送邮件解决
JS continues to explore...
PCB中常用快捷键
Similarities and differences of sessionstorage, localstorage and cookies
Exercise 6-2 using functions to sum special A-string sequences
Metal organic framework material zif-8 containing curcumin( [email protected] Nanoparticles) | nano metal organic framework carry
[acnoi2022] guess numbers
jvm-运行时数据区
Polestar美股上市:5.5万台交付如何支持得起超200亿美元估值