Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
Home Page
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Update your info
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
User ID:
Password:
  Register

2341 怎么判断输入结束呢??

Posted by Judas at 2005-08-04 13:42:06 on Problem 2341
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:
User ID:
Password:
Title:

Content:

Home Page   Go Back  To top


All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator