当前位置:网站首页>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 边栏推荐
猜你喜欢

可视化工具Netron介绍

【科研】文献下载神器方式汇总

Apache Doris系列之:安装与部署详细步骤

IJCAI2022 Tutorial | Spoken Language Comprehension: Recent Advances and New Fields

MySQL 8.0.29 decompressed version installation tutorial (valid for personal testing)

2022/07/30 学习笔记 (day20) 面试题积累

【MySQL】MySQL中对数据库及表的相关操作

PyTorch模型导出到ONNX文件示例(LeNet-5)

【2022-05-31】JS逆向之易企秀

Golang go-redis cluster模式下不断创建新连接,效率下降问题解决
随机推荐
力扣题(2)—— 两数相加
TCP 连接 三次握手 四次挥手
matlab标量场作图
Gxlcms audio novel system/novel listening system source code
openim支持十万超级大群
科技的成就(三十一)
2sk2225 Substitute 3A/1500V Chinese Documentation【PDF Data Book】
“蔚来杯“2022牛客暑期多校训练营4 L.Black Hole 垃圾计算几何
一文详解:SRv6 Policy模型、算路及引流
2021GDCPC广东省大学生程序设计竞赛 H.History
mysql锁机制
抽象类和接口(学习笔记)
PS基础学习(一)
IJCAI2022 Tutorial | Spoken Language Comprehension: Recent Advances and New Fields
reindex win10
【MySQL】DQL相关操作
通过社交媒体建立个人IP的 5 种行之有效的策略
详解操作符
【导航规划】导航规划背景知识总结
grub 学习