/*------------------------------------------------------------------------
题目: 编写函数(upfst),要求读入一个英文文本行,将其中每个单词的第一个字母改
成大写,然后输出此文本行(这里"单词"是指由空格隔开的字符串)。
例如,若输入:I am a student to take the examination.,
则应输出:I Am A Student To Take The Examination.。
------------------------------------------------------------------------
注意:部分源程序给出如下。请勿改动主函数main或其它函数中给出的内容,仅在
Program-End之间填入若干语句。不要删除标志否则不得分。
----------------------------------------------------------------------*/
#include <stdlib.h>
#include<ctype.h>
#include<string.h>
#include<stdio.h>
/**********Program**********/
void upfst(char *chrstr)
{
int i;
if(chrstr[0]>='a'&&chrstr[0]<='z')
chrstr[0]-=32;
for(i=0;chrstr[i];i++)
{
if((chrstr[i]>='a'&&chrstr[i]<='z')&&chrstr[i-1]==' ')
chrstr[i]-=32;
}
}
/********** End **********/
int main()
{
char chrstr[81];
printf("\nPlease enter an English text line:\n");
gets(chrstr);
printf("\nBefore changing:\n %s",chrstr);
upfst(chrstr);
printf("\nAfter changing:\n %s\n ",chrstr);
}
02-20
632
02-20
1万+