Find Max And Second Max Number In Array Using C++ Source Code
========================================================================
#include<iostream>
using namespace std;
main()
{
int DATA[10] = { 55,30,25,70,100,50,30,90,25,60};
int K,M,N;//M=Maximum and N=2nd maximum
M=DATA[0];
N=DATA[1];
for( K = 3 ; K <= 10 ; K++ )
{
if( M < DATA[K] )
{
M = DATA[K] ;
}
else if (N < DATA[K] )
{
N = DATA[K] ;
}
}
cout<<M;
cout<<endl;
cout<<N;
int getch() ;
}
========================================================================
0 comments:
Post a Comment