找出数组中前二大的数

 1 int main(int argc, char** argv)
 2 {
 3 
 4 
 5     int array[] = { 1,2,1,4 };
 6     int top = 0, second = 1;
 7     for (size_t i = 1; i < 4; i++)
 8     {
 9         if (array[i] < array[top])
10         {
11             second = top;
12             top = i;
13         }
14         else if (array[i] < array[second])
15             second = i;
16     }
17     cout << top << ";" << second << endl;
18     return 0;
19 }
原文地址:https://www.cnblogs.com/zl1991/p/8427057.html