标签:tle namespace ios ams 长度 blog cstring 0ms class
一个句子中也许有多个连续空格,过滤掉多余的空格,只留下一个空格。
Hello world.This is c language.
Hello world.This is c language.
思路:
大模拟;
来,上代码:
#include<cstdio> #include<string> #include<cstring> #include<iostream> using namespace std; int len; char word[201]; int main() { gets(word); len=strlen(word); for(int i=1;i<len;i++) { if(word[i]==‘ ‘&&(word[i-1]==‘^‘||word[i-1]==‘ ‘)) word[i]=‘^‘; } for(int i=0;i<len;i++) { if(word[i]==‘^‘) continue; putchar(word[i]); } putchar(‘\n‘); return 0; }
标签:tle namespace ios ams 长度 blog cstring 0ms class
原文地址:http://www.cnblogs.com/IUUUUUUUskyyy/p/6105377.html