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

OpenCV笔记(二十):滤波函数——filter2D

mysql跨库关联查询(dblink)

鳄梨价格数据集(Avocado Prices)

通过对抗性知识蒸馏压缩深度图神经网络

Chapter 8 Intermediate Shell Tools II

StoneDB 为何敢称业界唯一开源的 MySQL 原生 HTAP 数据库?

IJCAI2022教程 | 口语语言理解:最新进展和新领域

Ningbo Zhongning Pawn will transfer 29.5% of the equity for 2.8338 million yuan, and the owner's equity in 2021 will be 9.6875 million yuan

MySQL连接时出现2003错误

一文详解:SRv6 Policy模型、算路及引流
随机推荐
反转链表-头插反转法
MySQL进阶sql性能分析
Day016 Classes and Objects
When Navicat connects to MySQL, it pops up: 1045: Access denied for user 'root'@'localhost'
#yyds干货盘点# 面试必刷TOP101:判断链表中是否有环
力扣题(2)—— 两数相加
Successfully resolved ModuleNotFoundError: No module named 'Image'
代码越写越乱?那是因为你没用责任链
StoneDB 为何敢称业界唯一开源的 MySQL 原生 HTAP 数据库?
grub learning
Golang 切片删除指定元素的几种方法
2sk2225代换3A/1500V中文资料【PDF数据手册】
连号区间数
Apache Doris series: detailed steps for installation and deployment
d使用among的问题
通过社交媒体建立个人IP的 5 种行之有效的策略
win10重建索引
PyTorch model export to ONNX file example (LeNet-5)
2022.7.30
ThinkPHP high imitation blue play cloud network disk system source code / docking easy payment system program