How to find the second largest number in an array of integers
This article introduces you how to find the second largest number in an integer array, the content is very detailed, interested friends can refer to, I hope it can be helpful to you.
It may be in the form of a story: for example, how to find the second big diamond if the elevator stops from the first floor to the tenth floor
1 # include 2 # include 3 # define MINNUMBER-32768 4 int find_sec_max (int arr [], int size) 5 {6 assert (arr); 7 int maxnumber=arr [0]; 8 int sec_max=MINNUMBER; 9 int item0; 10 for (iTunes 1 int imaxnumber) 13 {14 sec_max=maxnumber; 15 maxnumber=arr [I] 16} 17 else 18 {19 if (arr [I] > sec_max) 20 sec_max= arr [I]; 21} 22} 23 return sec_max; 24} 25 int main () 26 {27 int arr [10] = {3 printf:% d\ n ", find_sec_max (arr,10)) 29 return 0; 30}
Determine whether a single linked list has a ring?
1 # include 2 struct LinkNode 3 {4 char val; 5 LinkNode* next; 6}; 7 bool check (const LinkNode* head) 8 {9 if (head==NULL) 10 return false; 11 LinkNode* low=head,*fast=head- > next; 12 while (fast&&fast- > next) 13 {14 low=low- > next; 15 fast=fast- > next- > next; 16 if (low==fast) 17 return true 18} 19 return false; 20}
Find the largest of the two numbers: there are two int variables An and B. do not use if,?: and switch or other judgment statements, find the largest of the two numbers.
Option 1:
Int max= ((aqb) + abs (aMub)) / 2
Option 2:
Int (int) * 8-1)
Write a function that returns the value of 1 "2" 3 "n (assuming that the result does not exceed the range of long integer variables)
Int sum (int n) {return ((long) 1qn) * ncord 2;} about how to find the second largest number in an array of integers is shared here. I hope the above content can be helpful to you and you can learn more. If you think the article is good, you can share it for more people to see.