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 |
在自己的电脑上可以运行,为什么交上去就runTimeError呢?请大侠帮我看一下#include<iostream> using namespace std; int com(int *a,int alen,int tatal) { int i,j; int tp; int **b=new int*[a[alen-1]+1]; for(i=0;i<=a[alen-1];i++) { b[i]=new int[alen-1]; } for(i=0;i<a[alen-1]+1;i++) for(j=0;j<alen-1;j++) b[i][j]=a[j]; if(tatal==0) return 1; else if(tatal<0) return 0; else { for(i=0;i<=a[alen-1];i++) { tp=com(b[i],alen-1,tatal-(alen)*i); if(tp==1) return 1; } } delete []b; return 0; } int main() { int a[6]; int i,k=0;; int tatal; while(1) { for(i=0;i<6;i++) cin>>a[i]; if(a[0]==0&&a[1]==0&&a[2]==0&&a[3]==0&&a[4]==0&&a[5]==0) break; k++; cout<<"Collection #"<<k<<":"<<endl; tatal=a[0]*1+a[1]*2+a[2]*3+a[3]*4+a[4]*5+a[5]*6; if(tatal%2==1) { cout<<"Can't be divided."<<endl; continue; } tatal=tatal/2; if(com(a,6,tatal)==1) cout<<"Can be divided."<<endl; else cout<<"Can't be divided."<<endl; } return 0; } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator