fork download
  1. #include <stdio.h>
  2.  
  3. int * prefixSums ( int *a )
  4. {
  5. int i, r[5];
  6. r[0] = a[0];
  7.  
  8. for( i = 1; i < 5; i++ )
  9. r[i] = a[i] + r[i-1];
  10.  
  11. return r;
  12. }
  13.  
  14. int main ( void )
  15. {
  16. int i, test[5] = { 10, 5, 1, 1, 4 };
  17. int * res = prefixSums( test );
  18.  
  19. printf( "sums:" );
  20. for( i = 0; i < 5; i++ )
  21. printf( " %d", res[i] );
  22.  
  23. return 0;
  24. }
Runtime error #stdin #stdout 0s 2168KB
stdin
Standard input is empty
stdout

Standard output is empty