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.h> int testArrayLong(int *width) { int w=0; int *p; p=width; if(*p>0) { while(*p>0&&*p<=32767) { w++; p++; } } return w; } int testwidth(int *width,int length) { int mwidth[100]; int i=0,j=0; int *p; int w=0; int result; w=testArrayLong(width); for(j=0;j<w;j++) { mwidth[j]=0; for(;w>=1&&i<w&&(mwidth[j]+width[i])<=length;i++) { if(width[i]>length) { result=0;break;} mwidth[j]+=width[i]; } } for(result=mwidth[0],j=1;j<w;j++) { if(result<mwidth[j]) result=mwidth[j]; } return result; } int testheight(int *width,int *height,int length) { int i=0,j=0; int w=0; int mwidth[100]; w=testArrayLong(width); int high; int result=0; for(j=0;j<w&&height[i]!=-1;j++) { mwidth[j]=0; high=height[i]; for(;w>=1&&i<w&&(mwidth[j]+width[i])<=length&&height[i]!=-1;i++) { mwidth[j]+=width[i]; if(high<height[i]) high=height[i]; } result+=high; } return result; } void test(int *width,int *height,int length) { int w=0; int i=0,j=0; w=testArrayLong(width); for(i=0;j!=1&&i<w;i++) { if(width[i]<=length) j=0; else j=1; } if(j==0&&w!=0) cout<<testwidth(width,length)<<" x "<<testheight(width,height,length)<<endl; else if(w==0) cout<<0<<" x "<<0<<endl; } int main() { int length[100]; int width[100][15]; int height[100][15]; int i=0,j=0,n=0; cin>>length[0]; for(;length[j]!=0;j++) { cin>>width[j][0]>>height[j][0]; for(i=1;i>=1&&i<15&&width[j][i-1]!=-1&&height[j][i-1]!=-1;i++) { cin>>width[j][i]>>height[j][i]; } cin>>length[j+1]; } for(n=0;n<j;n++) { test(width[n],height[n],length[n]); } return 1; } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator