fork(3) download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. int main() {
  5. int n;
  6. cin >> n;
  7. double a[n];
  8. for(int i = 0; i < n ; ++i){
  9. cin >> a[i];
  10. }
  11. if(n >= 3){
  12. for(int i = 2; i < n; i+=3){
  13. double tmp = a[i - 1];
  14. a[i - 1] = (a[i] + a[i - 2])/2;
  15. a[i] = (tmp + a[i - 2])/2;
  16. }
  17. for(int i = 0; i < n ; ++i){
  18. cout << a[i] <<((i == n - 1)? "\n" : " ");
  19. }
  20. }
  21. return 0;
  22. }
Success #stdin #stdout 0s 3276KB
stdin
3 5 9 1
stdout
5 3 7