Answer Posted / rw-rwx
This might help.
max1=a[0];max2=a[1];
for(i=1;i<n;i++)
{
if(max1<a[i])
{
max2=max1;
max1=a[i];
}
if(max2==max1) max2=a[i+1];
if(max2==a[n]) { printf("All numbers are the same no second max.\n"); return 0;}
if(max2<a[i] && max1!=a[i]) max2=a[i];
}
| Is This Answer Correct ? | 0 Yes | 1 No |
Post New Answer View All Answers
Why do we use classes in programming?
What are structs in c++?
What is this weird colon-member (" : ") syntax in the constructor?
What is array in c++ pdf?
What does floor mean in c++?
What are the storage qualifiers?
How long does it take to get good at leetcode?
Why is c++ so fast?
Do class declarations end with a semicolon? Do class method definitions?
Is c++ an oop?
What is the best way to declare and define global variables?
What return value must conversion operators have in their declaration?
Can we make any program in c++ without using any header file and what is the shortest program in c++.
What are the advantages of c++ over c?
Can you declare an array without a size in c++?