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

为什么又WA了?

Posted by zAaron at 2006-12-02 21:08:41 on Problem 3095
#include <iostream>
#include <string>
using namespace std;
char str[80];

int Scan()
{
	int score,sum=0;
	bool flag;
//先从左向右扫描:
	flag = 0;
	for (int i=0; i<strlen(str); i++)
	{
		if (str[i] == '/' && flag == 0){ flag = 1 ; score = 100; } 
		else if (str[i] == '.'){ flag = 0; score = 100; }
		else if(str[i] == '|' && flag == 0) { flag = 1; score = 50; }
		else score = 0;
		sum += score;
	}	
//再从右向左扫描:
	flag = 0;
	for (--i; i>0; i--)
	{
		if (str[i] == '\\' && flag == 0){ flag = 1 ; score = 100; } 
		else if (str[i] == '.'){ flag = 0; score = 0; }//note
		else if(str[i] == '|' && flag ==0){ flag = 1; score = 50; }
		else score = 0;
		sum += score;
	}
	return sum/strlen(str) ;
}
 
int main()
{
	while(1)
	{
		gets(str);  
		if ( str[0] == '#') break;
		cout << Scan() << endl;
	}
	return 0;
}

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