标签:nbsp har page 过滤 长度 输出 menu 标记 include
一个句子中也许有多个连续空格,过滤掉多余的空格,只留下一个空格。
Hello world.This is c language.
Hello world.This is c language.
#include <iostream> #include <stdio.h> #include <string> #include <ctype.h> using namespace std; int main() { char ju[201]; int judge[201]; gets(ju); string sen = ju; int l = sen.size(); for(int i = 0; i < l; i++) { if(sen[i] == ‘ ‘ && judge[i-1] == 0) { judge[i] = 1; } else if(sen[i] == ‘ ‘ && judge[i-1] != 0) { judge[i] = judge[i-1] + 1; } else{ judge[i] = 0; } } for(int i = 0; i < l; i++) { if(judge[i] == 0 || judge[i] == 1) { cout << sen[i]; } } return 0; }
就是一个简单的标记方法。
标签:nbsp har page 过滤 长度 输出 menu 标记 include
原文地址:http://www.cnblogs.com/QingHuan/p/7008233.html