fork(1) download
  1. #include <iostream>
  2. using namespace std;
  3. int main()
  4. {
  5. while(true)
  6. {
  7. if(cin.eof())break;
  8. long long mx=0,x,prezent=0;
  9. while (cin>>x)
  10. {
  11. if(x==0)break;
  12. if (mx<x)prezent=mx;mx=x;
  13. }
  14. if (prezent==0)prezent=mx;
  15. cout<<prezent<<endl;
  16. }
  17. return 0;
  18. }
  19.  
Success #stdin #stdout 0s 15224KB
stdin
1 2 3 0
stdout
2
0