当前位置:网站首页>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;
}
边栏推荐
- 浅谈Multus CNI
- Hands on deep learning (41) -- Deep recurrent neural network (deep RNN)
- Hands on deep learning (34) -- sequence model
- Explanation of for loop in golang
- 回复评论的sql
- MySQL develops small mall management system
- Launpad | 基礎知識
- 2022-2028 global special starch industry research and trend analysis report
- Normal vector point cloud rotation
- Application of safety monitoring in zhizhilu Denggan reservoir area
猜你喜欢
The child container margin top acts on the parent container
Kubernetes CNI 插件之Fabric
Hands on deep learning (34) -- sequence model
Daughter love in lunch box
IIS configure FTP website
Regular expression (I)
PHP book borrowing management system, with complete functions, supports user foreground management and background management, and supports the latest version of PHP 7 x. Database mysql
PHP student achievement management system, the database uses mysql, including source code and database SQL files, with the login management function of students and teachers
C language pointer classic interview question - the first bullet
Hands on deep learning (37) -- cyclic neural network
随机推荐
Leetcode (Sword finger offer) - 35 Replication of complex linked list
C language pointer interview question - the second bullet
How can Huawei online match improve the success rate of player matching
libmysqlclient.so.20: cannot open shared object file: No such file or directory
Solution to null JSON after serialization in golang
Hands on deep learning (45) -- bundle search
Hands on deep learning (III) -- Torch Operation (sorting out documents in detail)
Hands on deep learning (43) -- machine translation and its data construction
Golang type comparison
什么是 DevSecOps?2022 年的定义、流程、框架和最佳实践
Hands on deep learning (40) -- short and long term memory network (LSTM)
2022-2028 global optical transparency industry research and trend analysis report
Global and Chinese market of planar waveguide optical splitter 2022-2028: Research Report on technology, participants, trends, market size and share
2022-2028 global small batch batch batch furnace industry research and trend analysis report
Upgrading Xcode 12 caused Carthage to build cartfile containing only rxswift to fail
2022-2028 global elastic strain sensor industry research and trend analysis report
Advanced technology management - how to design and follow up the performance of students at different levels
【leetcode】29. Divide two numbers
Hands on deep learning (42) -- bi-directional recurrent neural network (BI RNN)
Are there any principal guaranteed financial products in 2022?