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 what is oop?
Implement stack operations with pointers with appropriate exception checks.
How should runtime errors be handled in c++?
Why Pointers are not used in C++?
What are abstract data types in c++?
describe private access specifiers?
Write a recursive program to calculate factorial in c++.
Is java easier than c++?
What's the best free c++ profiler for windows?
Will this c++ program execute or not?
Reads in the size of a square from the screen; 2. Prints a hollow square of that size out of “-“, “|” and blanks on screen; 3. Prints the same hollow square onto a text file. Your program should work for squares of all side sizes between 1 and 20. --- │ │ │ │ │ │ ---
Who discovered c++?
Difference between struct and class in terms of access modifier.
What is #include iostream?
What are separators in c++?