[ create a new paste ] login | about

Link: http://codepad.org/9jpZPzyr    [ raw code | output | fork ]

C++, pasted on Dec 25:
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

void printInt(FILE* fp, const char* f, char* s) {
   char* x, *a, *b, *p;
   long i, t, n;
   x = NULL;
   if(! s)
        return;
   a = b = p = s;
   for(t = atoi(s); *s; ) {
      i = strtol(s, &x, 10);
      if(!(n = x - s))
         break;
      if(i <= t) {
          t = i;
          a = s;
          s += n;
          b = s;
          continue;
      }
      s += n;
   }	  
   fprintf(fp, f, t);
   strcpy(a, b);
   printInt(fp, f, strpbrk(p, "0123456789"));
}

int  main(void) {
  char str[128] = " 1000000 7000   5\t\n  300 350000 4300 \t 17 1111  -7  99 8 \n";
  printInt(stdout, "%d\n", str);
  return 0;
}


Output:
1
2
3
4
5
6
7
8
9
10
11
-7
5
8
17
99
300
1111
4300
7000
350000
1000000


Create a new paste based on this one


Comments: