fork download
  1. #include <stdio.h>
  2. #include <time.h>
  3.  
  4. #define BIG 1000000
  5.  
  6. int f( int n ) {
  7. int r = 0, i = 0;
  8. for ( i = 0; i < 1000; i++ ) {
  9. r += i;
  10. if ( n == BIG - 1 ) {
  11. return -1;
  12. }
  13. }
  14. return r;
  15. }
  16.  
  17. int main() {
  18. clock_t start = clock();
  19. int i = 0, z = 0;
  20. for ( i = 0; i < BIG; i++ ) {
  21. if ( (z = f(i)) == -1 ) {
  22. break;
  23. }
  24. }
  25. double t = (double)(clock() - start) / CLOCKS_PER_SEC;
  26. printf( "%f\n", t );
  27. printf( "%d\n", z );
  28. }
Runtime error #stdin #stdout 0.02s 1720KB
stdin
Standard input is empty
stdout
0.010000
-1