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

新手一只,求高手指点!wrong answer!!

Posted by wzdhlj2 at 2011-12-04 17:24:27 on Problem 1247
#include<iostream>
#include<vector>
using namespace std;
int main()
{
	int n,ella = 0,sam = 0;
	while(cin>>n)
	{
		int k = 0;
		if(n <= 0) break;
		if(n<2||n>30) return 0;
		vector<int> a(n);
		for(int i=0;i<n;i++)
			cin>>a[i];
		for(int m=0;m<n;m++)
		{
			sam = sam +a[m];
			for(k=n-1;k>m;k--)
			{	
				ella = ella + a[k];
			}
			if(sam == ella)
			{
				cout<<"Sam stops at position "<<m+1
				<<" and Ella stops at position "<<k+2<<"."<<endl;
				break;
			} else if(m == n-1){				
				cout<<"No equal partitioning."<<endl;
				break;
			}
			ella = 0;
		}
		sam = 0;
	}

	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