• #include <iostream>
  • #include <fstream>
  •  
  • using namespace std;
  •  
  • int main()
  • ...{
  •     ifstream inFile("d:\intArray.txt");
  •     if(!inFile)
  •         ...{
  •             cout<< "File Error"<<endl;
  •             return -1;
  •     }
  •  
  •     int len;
  •     inFile >> len;
  •     int* arrayInt = new int[len];
  •     for(int i = 0; i < len; i++)
  •         inFile >> arrayInt[i];
  •     int indexI = 0, indexII;
  •  
  •     if(arrayInt[0] < arrayInt[1])
  •         indexI = 0, indexII = 1;
  •     else
  •         indexI = 1, indexII = 0;
  •  
  •     for(int i = 1; i < len; i++)
  •         ...{
  •             if(arrayInt[i] > arrayInt[indexI])
  •                 ...{
  •                     indexII = indexI;
  •                     indexI = i;
  •             }
  •             else if(arrayInt[i] > arrayInt[indexII])
  •                 ...{
  •                     indexII = i;
  •             }
  •     }
  •  
  •     cout<<"The second biggest number is " << arrayInt[indexII]<<endl;
  •  
  •     delete[] arrayInt;
  •     return 0;
  • }
  • 相关文章:

    • 2021-08-08
    • 2021-08-20
    • 2022-01-15
    • 2021-04-10
    • 2022-12-23
    • 2022-01-15
    猜你喜欢
    • 2021-06-20
    • 2021-11-05
    • 2022-12-23
    • 2022-12-23
    • 2021-11-21
    • 2022-12-23
    • 2021-07-20
    相关资源
    相似解决方案