Foreword:
21 Postgraduate entrance examination, I am gnawing "Algorithm Notes", whether I can enter the retest or not to record the garbage code written on the road.
answer:
#include<cstdio>
#define max 105
int main()
{
char str[max];
for(int i=0;i<max;i++)
str[i]='\0';
while(gets(str)!=NULL){
for(int p=0;str[p]!='\0';p++)
if(p==0||str[p-1]==' '||str[p-1]=='\t'||str[p-1]=='\r'||str[p-1]=='\n')
// 对于第一个字符和前一个字符为空白符的字符大写
printf("%c",str[p]-32);
else
printf("%c",str[p]);
printf("\n");
for(int i=0;i<max;i++)
str[i]='\0';
}
return 0;
}
It can only be half right, and I really haven't found out what's wrong.