http://ideone.com/HWAFoM

Mã:
#include<iostream>#include<string.h>#include<string>using namespace std; void chen(char str[], int i){    for (int j = strlen(str); j>i; j--)    {        str[j] = str[j - 1];    }    str[i] = ',';} main(){    char str[50];    cin.getline(str, 50);    if (strlen(str) <= 3) cout << str;    else    {        int a = 0, count = -1;        for (int i = strlen(str) - 1; i>0; i--)        {            a++;            if (a == 3) chen(str, i), a = 0, count++;        }        for (int i = 0; i<strlen(str) + count; i++)        {            cout << str[i];        }    }}
đề bài: http://www.spoj.com/PTIT/problems/BCCOMMAS/
số có 4 chữ số trở lên ko có output gì cả, mà trong máy e vẫn chạy bình thường