Salut! Ti-am facut o sursa C++ exact pe ideea indicata de tine...functioneaza. Succes!
#include <bits/stdc++.h>
using namespace std;
int n, ct, nr;
double x, max1, max2;
int main()
{
ifstream f("numere.txt");
f >> x;
nr = 1;
ct = 1;
max1 = max2 = x;
while(f >> x)
{
nr ++;
if(x > max1) max2 = max1, max1 = x;
else
{
if(x > max2) max2 = x;
if(x == max1) ct ++;
}
}
if(ct == nr) cout << "IMPOSIBIL";
else cout << max1 << " " << max2;
return 0;
}