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.h> int aa(int *a); void main() { int a[6]={0},b[999]={0},time=0; while(1) { for(int 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; else { b[time]=aa(a); time++; } } for(int j=0;j<time;j++) cout<<b[j]<<endl; } int aa(int *a) { int number=0; if(a[5]) number += a[5]; if(a[4]) { number += a[4]; if(a[0]>=a[4]*11) a[0]=a[0]-a[4]*11; else a[0]=0; } if(a[3]) { number += a[3]; if(a[3]*5>=a[1]) { if((a[3]*5-a[1])*4>=a[0]) a[0]=0; else a[0]=a[0]-(a[3]*5-a[1])*4; a[1]=0; } else { a[1]=a[1]-a[3]*5; } } if(a[2]) { int rest=a[2]%4; int rest1= (a[2])/4; number += rest1; if(rest==1) { if(a[1]>=5) { a[1] -= 5; if(a[0]>=7) a[0] -= 7; else a[0]=0; } else { if(a[0]>=(5-a[1])*4+7) a[0] -= (5-a[1])*4+7; else a[0]=0; a[1]=0; } number++; } if(rest==2) { if(a[1]>=3) { a[1] -= 3; if(a[0]>=6) a[0] -= 6; else a[0]=0; } else { if(a[0]>=(3-a[1])*4+6) a[0] -= (3-a[1])*4+6; else a[0]=0; a[1]=0; } number++; } if(rest==3) { if(a[1]>=1) { a[1] -= 1; if(a[0]>=5) a[0] -= 5; else a[0]=0; } else { if(a[0]>=9) a[0] -= 9; else a[0]=0; a[1]=0; } number++; } } if(a[1]) { int left=a[1]%9; int left1=(a[1])/9; number += left1; if(left!=0) { if(a[0]>=36-left*4) { a[0] -= 36-left*4; number++; } else { a[0]=0; number++; } } } if(a[0]) { if(a[0]%36==0) number += (a[0]-a[0]%36)/36; else number += (a[0]-a[0]%36)/36+1; } return number; } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator