char* countAndSay(int n) {
char* result =calloc(sizeof(char) ,5000);
memset(result, 0, sizeof(char) *5000);
char* tmp = calloc(sizeof(char),5000);
memset(tmp, 0, sizeof(char) * 5000);
if (n == 1)
return "1";//递归出口
tmp = countAndSay(n - 1);
int jishu=0,len=0,i=0;
char zj=tmp[0];
while(len<=strlen(tmp)){
if(zj==tmp[len])
jishu++;
else{
result[i++]=jishu+'0';
result[i++]=zj;
zj=tmp[len];
jishu=1;
}
len++;
}
result[i]='\0';
return result;
}
08-06
217
![](https://csdnimg.cn/release/blogv2/dist/pc/img/readCountWhite.png)
08-07
218
![](https://csdnimg.cn/release/blogv2/dist/pc/img/readCountWhite.png)