| ||||||||||
| Online Judge | Problem Set | Authors | Online Contests | User | ||||||
|---|---|---|---|---|---|---|---|---|---|---|
| Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest | |||||||||
while(gets(str))就行了,不要再加if(str[0]=='\0')break;In Reply To:2341 怎么判断输入结束呢?? Posted by:Judas at 2005-08-04 13:42:06 > Source
>
> Problem Id:2341 User Id:Judas
> Memory:56K Time:0MS
> Language:C++ Result:Wrong Answer
>
> Source
>
> #include<iostream.h>
> #include<stdio.h>
>
> void main()
> {
> char str[10001],c;
> int sum=0;
> int flag=1;
> while(gets(str))
> {
> if ( flag==1 && str[0]>='a' && str[0]<='z' ) sum++;
> flag=0;
> for(int i=0;(c=str[i])!='\0';i++)
>
> {
> if (c!=' ' && c!='\0' && c!='.' && c!=',' && c!=';' && c!=':' && c!='-' && c!='!' && c!='?' && str[i+1]>='A' && str[i+1]<='Z' )
> sum++;
> if ( (c=='.'||c=='?'||c=='!') && str[i+1]>='a' && str[i+1]<='z' )
> sum++;
> }
> if (str[i-1]=='.'||str[i-1]=='?'||str[i-1]=='!') flag=1;
> if (str[0]=='\0') break;
> }
> cout<<sum<<endl;
> }
>
Followed by:
Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator