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

水题!贴代码了……

Posted by 0810311106 at 2009-08-14 18:48:17 on Problem 3095
#include"stdio.h"
#include"string.h"
int main()
{
	char a[100];
	while(scanf("%s",&a)&&strcmp(a,"#")!=0)
	{
		float result=0.0;
		int i,j;
		int len;
		len=strlen(a);
		for(i=0;i<len;i++)
		{
			if(a[i]=='/')
			{
				if(i==0)
				result+=100;
				for(j=i-1;j>=0;j--)
				if(a[j]=='\\'||a[j]=='|')
				{
					break;
				}
				else if(a[j]=='.'||j==0)
				{
					result+=100;
					break;
				}
			}
			else if(a[i]=='\\')
			{
				if(i==len-1)
				result+=100;
				for(j=i+1;j<len;j++)
				if(a[j]=='/'||a[j]=='|')
				{
					break;
				}
				else if(a[j]=='.'||j==len-1)
				{
					result+=100;
					break;
				}
			}
			else if(a[i]=='|')
			{
				if(i==len-1)
				result+=50;
				for(j=i+1;j<len;j++)
				if(a[j]=='/'||a[j]=='|')
				{
					break;
				}
			    else if(a[j]=='.'||j==len-1)
				{
					result+=50;
					break;
				}
				if(i==0)
				result+=50;
				for(j=i-1;j>=0;j--)
				if(a[j]=='\\'||a[j]=='|')
				{
					break;
				}
				else if(a[j]=='.'||j==0)
				{
					result+=50;
					break;
				}
				
			}
			else if(a[i]=='.')
			result+=100;
		}
		result/=len;
		printf("%d\n",(int)result);
	}
	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