Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
Home Page
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Update your info
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
User ID:
Password:
  Register

Re:What-Wash your mouth then ask!

Posted by xuerdawas at 2003-06-28 20:52:32 on Problem 1076
In Reply To:What's the fucking Presentation Error?! Posted by:xiaomi at 2003-06-24 17:01:28
> #include <iostream.h>  
> 
> int n,i,j,k,l,rest=0;  
> char (*bowler);  
> int pin[30];  
> char record [15] [3];  
> int score[15] ;  
> 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()  
> {  
>     bowler=new char [12];  
>     for (i=0;i<12;i++)  
>         bowler[i]=32;  
>     for (i=0;i<15;i++)  
>         for (j=0;j<3;j++)  
>             record[i][j]=32;  
>     for (i=0;i<30;i++)  
>         pin[i]=-1;  
>     j=0;  
>       
>     while(cin>>bowler)  
>     {  
>         do  
>         {  
>             cin>>pin[j];  
>             j++;  
>         }  
>         while (pin[j-1]!=-1);//input  
> 
> 
>         i=0;  
>         do  
>         {  
>             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++;  
>         }  
>         while (pin[i]!=-1);  
>         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--;  
>             //record  
>         if ((record[k][0]>=49&&record[k][0]<=57)||(record[k][0]==45))  
>             k++;  
>         if (record[k-1][0]==32) 
>             k--; 
>         i=0;  
>         score[0]=0;  
>         do  
>         {  
>             score[l]+=sco(pin[i],pin[i+1],pin[i+2]);  
>             score[l+1]=score[l];  
>             if (stop==true)  
>                 break;  
>             l++;  
>             i++;  
>         }  
>         while ((pin[i]!=-1)&&(l<10));//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<15;i++)  
>             for (j=0;j<3;j++)  
>             record[i][j]=32;  
>         for (i=0;i<30;i++)  
>             pin[i]=-1;  
>         i=j=k=l=rest=0;  
>         stop=spare=false;  
>     }  
> 
>     return 0;  
> }  

Followed by:

Post your reply here:
User ID:
Password:
Title:

Content:

Home Page   Go Back  To top


All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator