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

不要用cin

Posted by 20053565 at 2007-06-21 18:40:00 on Problem 2341
In Reply To:为什么WA阿 Posted by:20053565 at 2007-06-21 15:30:31
> #include <iostream>
> 
> using namespace std;
> 
> int is(char ch)
> {
> 	if((ch>='a'&&ch<='z')||(ch>='A'&&ch<='Z'))
> 		return 1;
> 	return 0;
> }
> 
> int main()
> {
> 	int i, wrong = 0;
> 	char word[10001];
> 
> 	i = 0;
> 	while(cin>>word[i])
> 	{
> 		if(word[i]=='.'||word[i]=='!'||word[i]=='?')
> 		{
> 			word[i+1] = '\0';
> 			i = 0;
> 			while(!is(word[i]))
> 				i++;
> 			if(word[i]<='z'&&word[i]>='a')
> 				wrong++;
> 			for(i = 1; word[i]!='\0'; i++)
> 			{
> 				if(word[i]>='A'&&word[i]<='Z'&&is(word[i-1]))
> 					wrong++;
> 			}
> 			i = -1;
> 		}
> 		i++;
> 	}
> 	cout<<wrong;
> 	return 1;
> }

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