《算法笔记》3.6小节——入门模拟->字符串处理
B题本身没有难度,因为样例后面不是'\n',好心的管理员帮忙修改了样例,明天看一下在初始状态下怎么解决这个问题
#include<stdio.h> #include<string.h> int main() { char c[1000]; int count=0; bool pd=true; while(scanf("%c",&c[count])!=EOF) { if(c[count]!='\n') { if(pd==true) { if(c[count]>='a'&& c[count]<='z') c[count]=c[count]+'A'-'a'; pd=false; } else if(c[count]==' ' || c[count]=='\t'||c[count]=='\r' ||c[count]=='\n') { pd=true; } count++; } else { for(int i=0;i<count;i++) printf("%c",c[i]); printf("\n"); pd=true; count=0; } } return 0; }
时间才能证明一切,选好了就尽力去做吧!