天, 写的好复杂啊, 用sprintf或则直接进行类型转换就可以了(按位)
s[0]=i/1000+'0';;
j=i-(i/1000)*1000;
i=j;
s[1]=i/100+'0';;
j=i-(i/100)*100;
i=j;
s[2]=i/10+'0';
s[3]='\0';
cout << s << endl;
s[0]=i/1000+'0';;
j=i-(i/1000)*1000;
i=j;
s[1]=i/100+'0';;
j=i-(i/100)*100;
i=j;
s[2]=i/10+'0';
s[3]='\0';
cout << s << endl;