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 |
看看这段代码,为什么不能通过?#include<iostream> #include<cstdlib> using namespace std; int sum[20]; void output(int n) { int i; if(n==0){ cout<<"{}";return ;} else { cout<<"{"; for(i=0;i<n;i++) { output(i); if(i!=n-1)cout<<","; } cout<<"}"; } return ; } int count(char *a) { int i,la=strlen(a),t=0; if(la==2) return 0; for(i=0;i<la;i++) if(a[i]==',')t++; for(i=1;i<16;i++) if(t==sum[i]) return i; } int main() { int i,j,n,total; char a[50000],b[50000]; sum[0]=0; sum[1]=0; for(i=2;i<16;i++) { sum[i]=i-1; for(j=2;j<i;j++) sum[i]+=sum[j]; } cin>>n; i=0; while(i<n) { i++; memset(a,0,sizeof(a)); cin>>a; cin>>b; total=count(a)+count(b); output(total); cout<<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