while(cin>>aa)
{
cnt=0;
const char d = " ±/=<>:(),;.";
char p;
///运用空格和运算符和界符分割字符串并且遍历
char buf[1001] ;
strcpy(buf , aa.c_str()); //字符串转成数组
p = strtok(buf,d); //p是一个char
while§
{
if(aa[cnt]==p[0]) //当前无符号
{
feifuhao§;
cnt=cnt+strlen§;
}
else ///当前是符号
{
fuhao(aa,cnt);
cnt=change(aa,cnt);
cnt=cnt+1;
feifuhao§;
cnt=cnt+strlen§;
}
p=strtok(NULL,d); //下移一位,进行遍历
}
strtok分割字符串(按照指定多个字符分割)
最新推荐文章于 2023-09-25 22:24:04 发布