Answer Posted / fish
int a1(int[] a)
{
int max1 = -1;
int max2 = -1;
for (int i=0; i<a.length; i++)
{
if (a[i] > max1)
{
max2 = max1;
max1 = a[i];
}
else if (a[i] != max1 && a[i] > max2)
max2 = a[i];
}
return max2;
}
Is This Answer Correct ? | 0 Yes | 1 No |
Post New Answer View All Answers
Explain the problem with overriding functions
How c functions prevents rework and therefore saves the programers time as wel as length of the code ?
Do we have to use initialization list in spite of the assignment in constructors?
What is the type of this pointer in c++?
What relational operators if statements in c++?
What is the arrow operator in c++?
What is auto used for in c++?
What is #include math h in c++?
Inline parameters : What does the compiler do with the parameters of inline function, that can be evaluated in runtime ?
What is extern c++?
Is c++ faster than c?
the first character in the variable name must be an a) special symbol b) number c) alphabet
Why do we use templates?
What are the sizes and ranges of the basic c++ data types?
Where can I run c++ program?