|
|
back to boardWhy I have WA 3 ?????? int Capital(char c) { if(c>='A' && c<='Z') return(1); else return(0); } int Small(char c) { if(c>='a' && c<='z') return(1); else return(0); } int Punctual(char c) { if(!Small(c) && !Capital(c)) return(1); else return(0); } int main() { char a[10001],c; int tl=0,i; freopen("input.txt","r",stdin); while(scanf("%c",&c)>0) { if(c!='\n') a[tl++]=c; } int begsent=1,res=0; for(i=0;i<tl;i++) { if(begsent && Small(a[i])) res++; if(i>0 && !Punctual(a[i-1]) && Capital(a[i])) res++; if(begsent && !Punctual(a[i])) begsent=0; else if(!begsent && a[i]=='?' || a[i]=='.' || a[i]=='!') begsent=1; } printf("%d\n",res); return 0; } Re: Why I have WA 3 ?????? Try to read a line symbol-by-symbol, instead of entirely at once. When you will read a symbol, determine the status (the new paragraph (offer), whether there was a capital letter and so on). Then you will count amount of mistakes. I have written the Pascal language program and have received "Accepted" (0.015seconds with allocation of memory 133kBytes) Edited by author 04.06.2005 14:37 |
|
|