当前位置:网站首页>Exercise 7-2 finding the maximum value and its subscript (20 points)
Exercise 7-2 finding the maximum value and its subscript (20 points)
2022-07-04 09:47:00 【skeet follower】
This question requires the preparation of procedures , Find the given n The maximum number and its corresponding minimum subscript ( Subscript from 0 Start ).
Input format :
Input gives a positive integer in the first line n(1<n≤10). Second line input n It's an integer , Separate with spaces .
Output format :
Output the maximum value and the minimum subscript of the maximum value in one line , Separated by a space .
sample input :
6
2 8 10 1 9 10
sample output :
10 2
The code is as follows :
#include<stdio.h>
int main()
{
int n,i,j,max=0;
scanf("%d",&n);
int a[n];
for(i=0;i<n;i++){
scanf("%d",&a[i]);
}
for(i=1;i<n;i++){
if(a[i]>a[max]){
max=i;
}
}
printf("%d %d\n",a[max],max);
return 0;
}
边栏推荐
- Go context 基本介绍
- Launpad | Basics
- C # use gdi+ to add text to the picture and make the text adaptive to the rectangular area
- Regular expression (I)
- PHP is used to add, modify and delete movie information, which is divided into foreground management and background management. Foreground users can browse information and post messages, and backgroun
- Investment analysis and future production and marketing demand forecast report of China's paper industry Ⓥ 2022 ~ 2028
- 2022-2028 global protein confectionery industry research and trend analysis report
- 2022-2028 global visual quality analyzer industry research and trend analysis report
- 品牌连锁店5G/4G无线组网方案
- C # use ffmpeg for audio transcoding
猜你喜欢
MySQL develops small mall management system
品牌连锁店5G/4G无线组网方案
Web端自动化测试失败原因汇总
2022-2028 global intelligent interactive tablet industry research and trend analysis report
Hands on deep learning (III) -- Torch Operation (sorting out documents in detail)
165 webmaster online toolbox website source code / hare online tool system v2.2.7 Chinese version
C # use gdi+ to add text with center rotation (arbitrary angle)
2022-2028 global industrial gasket plate heat exchanger industry research and trend analysis report
MATLAB小技巧(25)竞争神经网络与SOM神经网络
Kubernetes CNI 插件之Fabric
随机推荐
Multilingual Wikipedia website source code development part II
Les différents modèles imbriqués de listview et Pageview avec les conseils de flutter
Global and Chinese market of bipolar generators 2022-2028: Research Report on technology, participants, trends, market size and share
Machine learning -- neural network (IV): BP neural network
2022-2028 global seeder industry research and trend analysis report
Write a jison parser from scratch (2/10): learn the correct posture of the parser generator parser generator
Golang Modules
智能网关助力提高工业数据采集和利用
SQL replying to comments
Go context 基本介绍
Report on investment analysis and prospect trend prediction of China's MOCVD industry Ⓤ 2022 ~ 2028
mmclassification 标注文件生成
System.currentTimeMillis() 和 System.nanoTime() 哪个更快?别用错了!
Basic data types in golang
Kotlin set operation summary
Upgrading Xcode 12 caused Carthage to build cartfile containing only rxswift to fail
技术管理进阶——如何设计并跟进不同层级同学的绩效
xxl-job惊艳的设计,怎能叫人不爱
On Multus CNI
Hands on deep learning (44) -- seq2seq principle and Implementation