Code Snippet
- #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;
- }