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

Re:求助!!!帮我看一下,麻烦大家了WA

Posted by scauben0 at 2005-11-25 00:29:21 on Problem 1247
In Reply To:Re:求助!!!帮我看一下,麻烦大家了WA Posted by:ffff at 2005-05-09 23:29:46
#include<stdio.h>
#include<string.h>
void main()
{
    long a[100]; long i,j,s,s1,m;
	freopen("1.txt","r",stdin);
    scanf("%ld",&a[0]);
	j=0;i=0;
	while(a[0])
	{
		j=1;
		s=0;
		while(j<=a[0])
		{
		    scanf("%ld",&a[j]);
			j++;
		}
		i=j;
		j=1;
		while(j<=a[0])
		{
		    s+=a[j];
			j++;
		}
		j=1;
		s1=0;
		int flag=0;
		if(s%2==1) j=999999;
		while(j<=a[0])
		{
			s1+=a[j];
			j++;
			if(s1==s/2)
			{ flag=1;m=j-1;break;}
			if(s1>s/2) break;

		}
		if(flag) printf("Sam stops at position %ld and Ella stops at position %ld.\n",m,m+1);
		else printf("No equal partitioning.\n");
        scanf("%ld",&a[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