用C语言编程实现如下功能 要求精简
发布网友
发布时间:2022-04-26 02:47
我来回答
共1个回答
热心网友
时间:2022-05-02 21:15
int main()
{
char *pStr = "****a*c*def**";
int nLen = strlen(pStr) + 1;
char *P = new char[nLen];
int nCount = 0,nSize = 0;
while(*pStr != '\0')
{
if (*pStr == '*')
{
nCount ++;
}
else
{
break;
}
*pStr ++;
}
strcpy(P,pStr);
for (int i = 0;i < nCount;i ++)
{
P[nLen - nCount - 1 + i] = '*';
}
if (*P)
{
delete P;
}
return 0;