如果发现广告等破坏行为,请尽量将条目恢复到较早的版本而不是把相应内容直接删除,谢谢合作。
URAL/1601
来自"NOCOW"
< URAL
太简单了,逐个模拟判断 Pascal版 var ch:char; bk:boolean; begin bk:=true; while not eof(input) do begin read(ch); if (ch>='A')and(ch<='z') then begin if bk then begin write(ch); bk:=false; end else write(chr(ord(ch)+32)); end else if (ch='.')or(ch='?')or(ch='!') then begin bk:=true; write(ch); end else write(ch); end; end. //by yzxshuaige123
太简单了,逐个模拟判断 c++版: #include<stdio.h> #include<string.h> int main(){ char c; bool bk=1; while(scanf("%c",&c)!=EOF){ if(c>='A'&&c<='z'){ if(bk){ printf("%c",c);bk=0;} else printf("%c",c+32); } else if(c=='.'||c=='?'||c=='!') {bk=1;printf("%c",c);} else printf("%c",c); } return 0; } //by yzxshuaige123(楼下那几匹菜鸟还说我不行^^,哈哈,c++与PASCAL并存)
#include<stdio.h> #include<ctype.h> int main() { int n; char ch; bool b=false; while (scanf("%c",&ch)!=EOF) { if(!b) { if(isalpha(ch)) b=true; if(ch<='z'&&ch>='a') printf("%c",ch-32); else printf("%c",ch); if(ch=='.'||ch=='?'||ch=='!') b=false; } else{ if(ch<='Z'&&ch>='A') printf("%c",ch+32); else printf("%c",ch); if(ch=='.'||ch=='?'||ch=='!') b=false; } } return 0; } //by rzhpp
#include<stdio.h> #include<ctype.h> #include<string.h> char s[10001]={0},tmp[10001]={0}; void downcase() { int i; for(i=0;i<strlen(s);i++) if((isalpha(s[i]))&&(s[i]<97)) s[i]+=32; } bool find(int x) { while((x-1>=0)) { if(isalpha(s[x-1]))return false; if((s[x-1]=='.')||(s[x-1]=='!')||(s[x-1]=='?'))return true; x-=1; } return true; } int main() { int i,len,len2; while(gets(tmp)) { len=strlen(s); for(i=0;i<strlen(tmp);i++) s[len+i]=tmp[i]; s[len+i]='\n';s[len+i+1]='\0'; } downcase(); for(i=0;i<strlen(s);i++) if((isalpha(s[i]))&&(find(i))) s[i]-=32; puts(s); return 0; } //by wzm