code example



int main(int argc, char *argv[]) {
  int n = ...;
  float *x, *y;
  x = new float[n+1];
  y = new float[n+1];

  ... // fill x, y

  // do computation
  float e = 0;
  for (int i=1; i<n; ++i) {
   x[i] += ( y[i+1] + y[i-1] )*.5;
   e += y[i] * y[i];
  }

  ... // output x, e

  delete[] x, y;
  return 0;
}

[start] [references] [download] [install]