第一个:
printf("%04d", 12);第二个自己用程序实现吧.
char s[] = "0123012340001";
int s = (strlen(s)%4 == 0)?strlen(s) : strlen(s) + 1;
int *ret = new int[s];
for(int i = 0; i < s; i ++)
{
char chTemp[5];
ZeroMemory(chTemp, 5);
strncpy(chTemp, s, i*4);
ret[i] = atoi(chTemp);
}//使用retdelete ret;
printf("%04d", 12);第二个自己用程序实现吧.
char s[] = "0123012340001";
int s = (strlen(s)%4 == 0)?strlen(s) : strlen(s) + 1;
int *ret = new int[s];
for(int i = 0; i < s; i ++)
{
char chTemp[5];
ZeroMemory(chTemp, 5);
strncpy(chTemp, s, i*4);
ret[i] = atoi(chTemp);
}//使用retdelete ret;
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货