1 / 29
文档名称:

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

格式:pdf   大小:107KB   页数:29页
下载后只包含 1 个 PDF 格式的文档,没有任何的图纸或源代码,查看文件列表

如果您已付费下载过本站文档,您可以点这里二次下载

分享

预览

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

上传人:陈潇睡不醒 2022/8/4 文件大小:107 KB

下载得到文件列表

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

相关文档

文档介绍

文档介绍:: .

{
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 =