Please input a string:
abcsda-as
please input the key want to delete:
a
bbcsd--ss
Press any key to continue
#include <iostream>
using namespace std;
main()
{
int i,j,nLen;
char str[100]="\0",key;
cout<<"Please input a string:"<<endl;
cin>>str;
cout<<"please input the key want to delete:"<<endl;
cin>>key;
nLen=strlen(str);
for (i=0;i<=nLen;i++)
{
if (str[i]=='a')
{
for (j=i;j<=nLen;j++)
{
str[i]=str[i+1];
}
nLen--;
}
}
cout<<str<<endl;
}
本文如未解决您的问题请添加抖音号:51dongshi(抖音搜索懂视),直接咨询即可。