fork download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. int main() {
  5.  
  6. int tab[1000];
  7. int i = 0;
  8. do {
  9. cin >> tab[i];
  10. i++;
  11. } while(tab[i-1]!=-1);
  12. cout << (tab[1]+tab[i-3]/2.0);
  13.  
  14. return 0;
  15. }
Success #stdin #stdout 0.01s 5268KB
stdin
1 2 3 4 10 -1
stdout
4