#include<stdio.h>
#include<string.h>
int main(int argc, char const *argv[])
{
char ch[20];
printf("请输入字符串ch:");
gets(ch);//gets遇到回车才会停止读取
int a=0;
for (int i = 0; i <sizeof(ch)/sizeof(ch[0]); i++)//循环整个字符串
{
if (ch[i]==' ')//判断当前是否为空格
{
a++; //读取空格个数
continue;//跳出本次循环执行下次循环
}
if (ch[i]!=' ')//判断当前不是空格
{
ch[i-a]=ch[i];//将当前字符向前移动i-a位
}
}
puts(ch);
return 0;
}
07-09
1万+
02-25
4606