[ create a new paste ] login | about

Link: http://codepad.org/1meQ6Ory    [ raw code | output | fork ]

C, pasted on Jun 13:
#include <stdio.h>
#define C 1000
void g(int n, int flag) {
  int m;
  if (n > 0) {
    m = n % C;
    g(n / C, 1);
    printf("%d", m);
    if (flag)
      printf(",");
    else
      printf("\n");
  }
}
void f(int n) { g(n, 0); }
int main() {
  f(123);
  f(4567);
  f(890123);
  f(4567890);
  f(1234567890);
  return 0;
}
/* end */


Output:
1
2
3
4
5
123
4,567
890,123
4,567,890
1,234,567,890


Create a new paste based on this one


Comments: