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