Advertisement
eddiehy

Untitled

Oct 3rd, 2015
98
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.51 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3.  
  4. int main()
  5. {
  6. int num;
  7. scanf ("%d",&num);
  8. int numofcomma=1;
  9. int firstclass;
  10. int* digit;
  11. int i;
  12. if (num/1000==0)
  13. {
  14. printf("%d",num);
  15. return 0;
  16. }
  17. while (num/1000>0)
  18. {
  19. digit=(int *)malloc(sizeof(int)*1);
  20. digit[numofcomma-1]=num%1000;
  21. firstclass=num/1000;
  22. numofcomma++;
  23. }
  24. for (i=numofcomma-1;i<=0;i--)
  25. {
  26. if (i==0)
  27. {
  28. printf ("%d",firstclass);
  29. }
  30. else
  31. {
  32. printf (",%03d",digit[i]);
  33. }
  34. }
  35. free(digit);
  36. return 0;
  37. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement