《用c语言除去字符串中多余的空格》由会员分享,可在线阅读,更多相关《用c语言除去字符串中多余的空格(2页珍藏版)》请在金锄头文库上搜索。
cpp/* Copyright (c) 2012, 烟台大学计算机学院* All rights reserved.* 文件名称:test.cpp* 完成日期:2012 年12月16日* 版本号:v1.0* 输入描述:无* 问题描述:出去字符串中多余的空格* 程序输出:整理好的句子* 问题分析:* 算法设计:略*/#includeusing namespace std;int main()char str=Only one space is allowed between the two words.;cout原始难看的句子:strendl; 天骄无双:int i=0,j=0;bool notSpace;while(strj= )j+;notSpace=true;while(strj!=0)if(strj!= )notSpace=true;stri+=strj+;else if(notSpace)notSpace=false;stri+=strj+;elsej+;stri=0;cout整理后的句子:strendl; 升邪:return 0;