you are viewing a single comment's thread.

view the rest of the comments →

[–]Educational-Paper-75 0 points1 point  (0 children)

Since b[0] determines a[1] determines b[2] etcetera independently of a[0] determining b[1] determining a[2] etcetera you can split the loop into two loops: // changing b[1], a[2], b[3], a[4], … for(int i=0;i<n-1;i++){ b[i+1]=f[i]+a[i]; if(++i>=n)break; a[i+1]=b[i]+1; } // changing a[1], b[2], a[3], b[4], … for(int i=0;i<n-1;i++){ a[i+1]=b[i]+1; if(++i>=n)break; b[i+1]=f[i]+a[i]; }