当前位置:网站首页>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]);
}
边栏推荐
- Exercise 8-7 string sorting
- 泰凌冲刺科创板:拟募资13亿 国家大基金与小米长江是股东
- LNMP环境mail函数不能发送邮件解决
- Metal organic framework (MOFs) antitumor drug carrier | pcn-223 loaded with metronidazole | uio-66 loaded with ciprofloxacin hydrochloride( Similarities and differences between Allegro, OrCAD, net alias, port, off page connector and how to select them
- Onmenusharetimeline custom shared content is invalid, and the title and icon are not displayed
- Webpage connection database ~ simple implementation of addition, deletion, modification and query complete code
- [Jilin University] information sharing of postgraduate entrance examination and re examination
- Nucleic acid modified metal organic framework drug carrier | pcn-223 metal organic framework encapsulated ad adamantane | zif-8 encapsulated adriamycin (DOX)
- Interface for querying IP home
猜你喜欢
Vite project commissioning
x86汇编语言-从实模式到保护模式 笔记
[email protected] Nanoparticles) | nano metal organic framework carry"/>
Metal organic framework material zif-8 containing curcumin( [email protected] Nanoparticles) | nano metal organic framework carry
Redis:字符串类型数据的操作命令
Exercise 6-1 classify and count the number of characters
愉悦资本新双币基金近40亿元完成首次关账
QT learning 20 standard dialog box in QT (middle)
Exercise 8-7 string sorting
中感微冲刺科创板:年营收2.4亿净亏1782万 拟募资6亿
npm install卡住与node-npy的各种奇怪报错
随机推荐
Raft 协议
concat和concat_ws()区别及group_concat()和repeat()函数的使用
Exercise 6-2 using functions to sum special A-string sequences
7-14 sum integer segments (C language)
FPGA test method takes mentor tool as an example
Collection of mobile adaptation related articles
Example analysis of QT learning 18 login dialog box
7-23 currency conversion (using array conversion)
[acnoi2022] guess numbers
7-4 BCD decryption (10 points)
一文了解微分段应用场景与实现机制
QT learning 21 standard dialog box in QT (Part 2)
simpleParallax. JS (create poor visual effects for website pictures)
天图投资冲刺港股:资产管理规模249亿 投了小红书与奈雪
Exercise 10-6 recursively find Fabonacci sequence
适用于XP的DDK
SSH访问控制,多次失败登录即封掉IP,防止暴力破解
Reflection -- basic usage
Redis:字符串類型數據的操作命令
Metal organic framework MOFs loaded with non steroidal anti-inflammatory drugs | zif-8 wrapped Prussian blue loaded quercetin (preparation method)