POJ 1247
1 #include<iostream> 2 using namespace std; 3 int main(){ 4 int guest_num,i,sam_num=0,sum=0; 5 int * guest; 6 do{ 7 sum=0; 8 sam_num=0; 9 cin>>guest_num; 10 if(guest_num == 0) break; 11 guest=new int[guest_num]; 12 for(i=0;i<guest_num;i++){ 13 cin >> guest[i]; 14 sum+=guest[i]; 15 } 16 for(i=0;i<guest_num;i++){ 17 sam_num+=guest[i]; 18 if(sum-sam_num==sam_num){ 19 cout<<"Sam stops at position "<<i+1<<" and Ella stops at position "<<i+2<<'.'<<endl; 20 break; 21 } 22 } 23 if(i==guest_num) 24 cout<<"No equal partitioning."<<endl; 25 delete guest; 26 }while(1); 27 return 0; 28 29 }
关注我的公众号,当然,如果你对Java, Scala, Python等技术经验,以及编程日记,感兴趣的话。
技术网站地址: vmfor.com