当前位置:网站首页>ZZULIOJ: 1120: the most value to exchange
ZZULIOJ: 1120: the most value to exchange
2022-07-30 22:56:00 【catch up】
1120: max swap
Time limit: 1 Sec Memory limit: 128 MB
[Status] [Discussion Board] [Submit] [Submit by:admin]
Title description
There is a sequence of integers of length n.Write a program that swaps the minimum value with the first number in a sequence, and then swaps the maximum value with the last number.Output the converted sequence.Write two functions MinIndex() and MaxIndex() to calculate the minimum and maximum subscripts, respectively.
int MinIndex(int a[], int n); //The function returns the index of the smallest element in the array a
int MaxIndex(int a[], int n); //The function returns the index of the largest element in the array a
The output of the array elements calls the function PrintArr().
Enter
The input consists of two lines.
The first line is a positive integer n (1≤n≤10).
The second line is a sequence of n positive integers to ensure that there are no repeated elements.
Output
Output the converted sequence.Separate the data with spaces.
Sample input Copy
55 4 1 2 3
Sample output Copy
1 4 3 2 5
Reference Code
#include #include void PrintArr(int a[], int n);int MinIndex(int a[], int n);int MaxIndex(int a[], int n);int insert(int a[], int n, int num);int main(){int a[10], n, i, j, b;scanf("%d", &n);for(i=0;ic){c=a[i];m=i;}}return m;}void PrintArr(int a[], int n){int i;for(i=0;i
边栏推荐
- Golang 切片删除指定元素的几种方法
- 通过社交媒体建立个人IP的 5 种行之有效的策略
- Py's pdpbox: a detailed introduction to pdpbox, installation, and case application
- Compressing Deep Graph Neural Networks via Adversarial Knowledge Distillation
- go版本升级
- # Dasctf 7月赋能赛 WP
- 【导航规划】导航规划背景知识总结
- ThinkPHP high imitation blue play cloud network disk system source code / docking easy payment system program
- 2022.7.30
- cnpm installation steps
猜你喜欢
反转链表-就地逆置法
2sk2225 Substitute 3A/1500V Chinese Documentation【PDF Data Book】
#yyds干货盘点# 面试必刷TOP101:判断链表中是否有环
#Dasctf July Enabler WP
第十九周进度(了解物联网基础知识)
# # yyds dry goods inventory interview will brush TOP101: to determine whether there is a part of the list
Navicat cannot connect to mysql super detailed processing method
Excel basic study notes
代码越写越乱?那是因为你没用责任链
StoneDB 为何敢称业界唯一开源的 MySQL 原生 HTAP 数据库?
随机推荐
Day016 类和对象
MySQL 5.7 detailed download, installation and configuration tutorial
@RequestBody、 @RequestParam 、 @PathVariable 和 @Vaild 注解
HF2022-EzPHP复现
mysql锁机制
Golang go-redis cluster模式下不断创建新连接,效率下降问题解决
IDEA usage skills
【MySQL】DQL相关操作
【科研】文献下载神器方式汇总
Collapse legacy apps
Go1.18升级功能 - 模糊测试Fuzz 从零开始Go语言
Gxlcms audio novel system/novel listening system source code
“蔚来杯“2022牛客暑期多校训练营4 DHKLN
Go语学习笔记 - gorm使用 - gorm处理错误 Web框架Gin(十)
一文详解:SRv6 Policy模型、算路及引流
【无标题】
win10重建索引
力扣题(2)—— 两数相加
代码越写越乱?那是因为你没用责任链
使用LVS和Keepalived搭建高可用负载均衡服务器集群