| ||||||||||
| Online Judge | Problem Set | Authors | Online Contests | User | ||||||
|---|---|---|---|---|---|---|---|---|---|---|
| Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest | |||||||||
新手一只,求高手指点!wrong answer!!#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: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator