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 |
到底哪里表达错误了,这道题在zju上输入没有-1中止,是不是测试数据没改过来啊?#include <iostream.h> int n,i,j,k,l,rest; char bowler[12]; int pin[22]; char record [12] [3]; int score[11] ; bool stop,spare=false; int records; int scores; char rec(int a) { if ((a==0)&&(spare==false)) { return 88; } else if ((a==0)&&(spare==true)) { spare=false; return 47; } else if ((a!=0)&&(spare==false)) { spare=true; rest=a; if (a!=10) return 58-a; else return 45; } else { spare=false; if (a!=rest) return 48+rest-a; else return 45; } } int sco(int a,int b,int c) { if (a==0) { if (c!=-1) return b==0?30-c:20-c; else { stop=true; return 0; } } else if (b==0) { if (c!=-1) { i++; return 20-c; } else { stop=true; return 0; } } else { if (b!=-1) { i++; return 10-b; } else { stop=true; return 0; } } } int main() { for (i=0;i<12;i++) bowler[i]=32; for (i=0;i<12;i++) for (j=0;j<3;j++) record[i][j]=32; for (i=0;i<22;i++) pin[i]=-1; n=i=j=k=l=rest=0; stop=spare=false; while(cin>>bowler) { do { cin>>pin[j]; j++; } while (pin[j-1]!=-1); pin[21]=-1; //input i=0; while (pin[i]!=-1) { if (spare==false) record[k][0]=rec(pin[i]); else record[k][1]=rec(pin[i]); if (pin[i]==0) k++; else if (spare==false) k++; i++; } if ((record[10][0]!=32)&&(record[9][1]==32)) { record[9][1]=record[10][0]; if ((record[10][1]!=32)||((record[9][0]==88)&&(record[9][1]==88)&&(record[11][0]==32))) k--; record[10][0]=32; } else if (record[10][0]!=32) { record[9][2]=record[10][0]; if (record[10][0]==88) k--; record[10][0]=32; } if (record[10][1]!=32) record[9][2]=record[10][1]; record[10][1]=32; if (record[11][0]!=32) { record[9][2]=record[11][0]; k--; record[11][0]=32; } if ((record[9][0]==88)&&(record[9][1]==88)&&(record[9][2]==88)) k--; if ((record[k][0]>=49&&record[k][0]<=57)||(record[k][0]==45)) k++; if (k!=0) if (record[k-1][0]==32) k--; if (record[9][0]!=88&&record[9][1]!=47) record[9][2]=32; //record i=0; score[0]=0; while ((pin[i]!=-1)&&(l<10)) { score[l]+=sco(pin[i],pin[i+1],pin[i+2]); score[l+1]=score[l]; if (stop==true) break; l++; i++; } //score records=k; scores=l; for (i=0;i<12;i++) cout<<bowler[i]; for (i=0;i<records;i++) cout<<" "<<record[i][0]<<record[i][1]<<record[i][2]; cout<<endl<<" "; for (i=0;i<scores;i++) { if (score[i]<10) cout<<" "<<score[i]; else if (score[i]<100) cout<<" "<<score[i]; else cout<<" "<<score[i]; } cout<<endl<<endl; n++; for (i=0;i<12;i++) bowler[i]=32; for (i=0;i<12;i++) for (j=0;j<3;j++) record[i][j]=32; for (i=0;i<22;i++) pin[i]=-1; i=j=k=l=rest=0; stop=spare=false; } return 0; } Followed by:
Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator