下载此文档

中南民族大学C++实验四参考程序.pdf


文档分类:研究生考试 | 页数:约29页 举报非法文档有奖
1/29
下载提示
  • 1.该资料是网友上传的,本站提供全文预览,预览什么样,下载就什么样。
  • 2.下载该文档所得收入归上传者、原创者。
  • 3.下载的文档,不会出现我们的网址水印。
1/29 下载此文档
文档列表 文档介绍
: .

{
if('\n' == sentence[i])
sentence[i] = ' ';
sentence[i] = tolower(sentence[i]); // change all character to lower

if( is_first_letter && isalpha(sentence[i]))
{
is_first_letter = false; // is_first_letter is TRUE, means the character is the first
// character of the line, so change it to upper.
sentence[i] = toupper(sentence[i]);
}

if(' ' == sentence[i] && !have_blank)
have_blank = true; // the present character is blank, the flag of charactor
is FALSE,
// that means the last character is not blank,
// then set the flag of charactor with TRUE.
else if(' ' == sentence[i] && have_blank)
i--; // the present character is blank, the flag of charactor is
TRUE,
// that means the last character is blank, and there are
multiple blanks
// so that must compresses multiple blanks to one
capitalizes,
// the index of char array must sub, fall back one
element
else if(' ' != sentence[i] && have_blank)
have_blank = false; // the present character is not blank, the flag of charactor
is TRUE,
// that means the last character is blank,
// then must change the status of the flag of charactor,
// set have_blank with FALSE, reset with initial status
Page 2 of 29 Copyright By Xu, CS, ScuecOOP 第三次实验答案
}
if(i < 99)
sentence[i+1] = '\0';
else
{
sentence[98] = '.';
sentence[99] = '\0';
}

size = i;
}

void get_sentence( char str[], int& size)
{
int i = 0;
char next;

(next);
while(next != '.' && i<100)
{
str[i] = next;
(next);
i++;
}

str[i]='.';
str[i+1]='\0';

size =

中南民族大学C++实验四参考程序 来自淘豆网www.taodocs.com转载请标明出处.

相关文档 更多>>
非法内容举报中心
文档信息
  • 页数29
  • 收藏数0 收藏
  • 顶次数0
  • 上传人陈潇睡不醒
  • 文件大小107 KB
  • 时间2022-08-04