fork(1) download
  1. #include <stdio.h>
  2.  
  3. int main()
  4. {
  5. int a=-32768,b=-32768,temp=-32768;
  6. while(1)
  7. {
  8. scanf("%d",&a);
  9. if(a==-1)
  10. break;
  11. else if(a>0)
  12. {
  13. temp=b;
  14. b=a;
  15.  
  16. }
  17. else
  18. {
  19. if(a>b)
  20. {
  21. temp=b;
  22. b=a;
  23. }
  24. else
  25. {
  26. temp=b;
  27. }
  28. }
  29.  
  30. }
  31. printf("%d",temp);
  32. return 0;
  33. }
Success #stdin #stdout 0s 2056KB
stdin
7 6 3 4 1 2 3 5 -1
stdout
3