当前位置:网站首页>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 边栏推荐
- @RequestBody、 @RequestParam 、 @PathVariable 和 @Vaild 注解
- BFS题单总结
- 2022.7.28
- [MySQL] Related operations on databases and tables in MySQL
- 打动中产精英群体,全新红旗H5用产品力跑赢需求
- proxy反向代理
- WSL安装图形界面并通过xrdp/X-Launch访问
- # # yyds dry goods inventory interview will brush TOP101: to determine whether there is a part of the list
- PyTorch模型导出到ONNX文件示例(LeNet-5)
- grub 学习
猜你喜欢

VS2017 compile Tars test project

ThinkPHP高仿蓝奏云网盘系统源码/对接易支付系统程序

@RequestBody、 @RequestParam 、 @PathVariable 和 @Vaild 注解

$\text{ARC 145}$

Apache Doris系列之:深入认识实时分析型数据库Apache Doris

关于XML的学习(一)

Mysql进阶优化篇01——四万字详解数据库性能分析工具(深入、全面、详细,收藏备用)

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

Py之pdpbox:pdpbox的简介、安装、案例应用之详细攻略

MySql统计函数COUNT详解
随机推荐
language code table
阿里云视频点播+项目实战
"Code execution cannot continue because MSVCP140.dll was not found, reinstalling the program may resolve the problem, etc." Solutions
【Untitled】
VS2017 compile Tars test project
PhpMetrics usage
2022中国物流产业大会暨企业家高峰论坛在杭州举办!
[SAM模板题] P3975 [TJOI2015] 弦论
Go1.18升级功能 - 泛型 从零开始Go语言
IJCAI2022教程 | 口语语言理解:最新进展和新领域
MySQL联合查询(多表查询)
【云驻共创】HCSD大咖直播–就业指南
IDEA 连接 数据库
“蔚来杯“2022牛客暑期多校训练营4 N.Particle Arts 规律 方差
IDEA使用技巧
Computer shortcut icon whitening solution
#Dasctf July Enabler WP
reindex win10
使用LVS和Keepalived搭建高可用负载均衡服务器集群
Go语学习笔记 - gorm使用 - gorm处理错误 Web框架Gin(十)