当前位置:网站首页>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 10sample output :
10 2The 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;
}边栏推荐
- Machine learning -- neural network (IV): BP neural network
- DR6018-CP01-wifi6-Qualcomm-IPQ6010-IPQ6018-FAMILY-2T2R-2.5G-ETH-port-CP01-802-11AX-MU-MIMO-OFDMA
- Pcl:: fromrosmsg alarm failed to find match for field 'intensity'
- Global and Chinese market of air fryer 2022-2028: Research Report on technology, participants, trends, market size and share
- Mmclassification annotation file generation
- Write a jison parser from scratch (4/10): detailed explanation of the syntax format of the jison parser generator
- Global and Chinese market of bipolar generators 2022-2028: Research Report on technology, participants, trends, market size and share
- MySQL develops small mall management system
- How can Huawei online match improve the success rate of player matching
- Hands on deep learning (42) -- bi-directional recurrent neural network (BI RNN)
猜你喜欢

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

SSM online examination system source code, database using mysql, online examination system, fully functional, randomly generated question bank, supporting a variety of question types, students, teache

Normal vector point cloud rotation

回复评论的sql

Baidu R & D suffered Waterloo on three sides: I was stunned by the interviewer's set of combination punches on the spot

C语言指针经典面试题——第一弹

Hands on deep learning (45) -- bundle search

Hands on deep learning (37) -- cyclic neural network

Application of safety monitoring in zhizhilu Denggan reservoir area

C language pointer classic interview question - the first bullet
随机推荐
Fatal error in golang: concurrent map writes
Application of safety monitoring in zhizhilu Denggan reservoir area
2022-2028 global seeder industry research and trend analysis report
Daughter love in lunch box
技术管理进阶——如何设计并跟进不同层级同学的绩效
pcl::fromROSMsg报警告Failed to find match for field ‘intensity‘.
Hands on deep learning (37) -- cyclic neural network
MySQL foundation 02 - installing MySQL in non docker version
C # use gdi+ to add text with center rotation (arbitrary angle)
Hands on deep learning (III) -- Torch Operation (sorting out documents in detail)
智慧路灯杆水库区安全监测应用
Hands on deep learning (39) -- gating cycle unit Gru
品牌连锁店5G/4G无线组网方案
Sort out the power node, Mr. Wang he's SSM integration steps
Problems encountered by scan, scanf and scanln in golang
智能网关助力提高工业数据采集和利用
Kotlin set operation summary
2022-2028 global small batch batch batch furnace industry research and trend analysis report
QTreeView+自定义Model实现示例
Write a jison parser (7/10) from scratch: the iterative development process of the parser generator 'parser generator'