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<stdio.h> int newfill(int order[]);//填充邮包 void mfull(int *volume,int order[]);//1*1规格件填隙 void full(int *volume,int order[],int i);//已放入2*2\4*4\5*5规格邮件填隙 void sfull(int *volume,int order[]);//填充了3*3规格邮填隙 int order[6]; void mfull(int *volume,int order[]){ if(*volume>=order[0]){ order[0]=0; *volume-=order[0]; } else{ order[0]=order[0]-*volume; *volume=0; } return; } void full(int *volume,int order[],int i){ int k; if(i==1) mfull(volume,order); else{ k=*volume/((5-i)*(5-i)); if(k>=order[4-i]){ *volume-=order[4-i]*((5-i)*(5-i)); order[4-i]=0; } else{ order[4-i]-=k; *volume=0; } if(*volume>0&&(4-i-1)>=0&&order[4-i-1]>0) if(*volume>order[0]){ order[0]=0; *volume-=order[0]; } else { order[0]-=*volume; *volume=0; } } return; } void sfull(int *volume,int order[]){ if(order[1]==0){ mfull(volume,order); return; } switch(*volume){ case(9): if(order[1]>0){ order[1]--; *volume=5; } mfull(volume,order); break; case(18): if(order[1]>=3){ order[1]-=3; *volume=6; } else{ order[1]=0; *volume=18-4*order[1]; } mfull(volume,order); break; case(27): if(order[1]>=5){ order[1]-=5; *volume=7; } else { order[1]=0; *volume=27-4*order[1]; } mfull(volume,order); break; } } int newfill(int order[]){ int k,i,j; int a=0; int *volume; int parcel=0; volume=&a; for(i=5;i>=0;i--){ k=i+1; while(order[i]>0){ j=6/k; if(order[i]>=j*j){ order[i]-=j*j; *volume=36-k*k*j*j; } else{ *volume=36-k*k*order[i]; order[i]=0; } parcel++; if(*volume>0&&i==2) sfull(volume,order); else if(*volume>0&&i<=5&&i>0) full(volume,order,i); } } return parcel; } void main(){ int i,number; int mark=0; for(i=0;i<=5;i++) { scanf("%d",&order[i]); if(mark==0&&order[i]!=0) mark=1; } if(mark==0) return;//输入数组 else number=newfill(order); printf("%d\n",number); return; } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator