Last active
          August 29, 2015 14:13 
        
      - 
      
- 
        Save 02015678/ef5677c8ee982fa6dcae to your computer and use it in GitHub Desktop. 
    GCC Solution for NKPC3 Bowling Ball 
  
        
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | #include<stdio.h> | |
| int ans=-1; | |
| char k=0,i,a[21]; | |
| short pts=-1; | |
| char chk(short pts) | |
| { | |
| char tmp; | |
| switch(a[pts]) | |
| { | |
| case 'X':tmp=10;break; | |
| case '/':tmp=10-chk(pts-1);break; | |
| case '-':tmp=0;break; | |
| default :tmp=a[pts]-'0'; | |
| } | |
| return(tmp); | |
| } | |
| void cal() | |
| { | |
| char tmp; | |
| if(a[++pts]=='X')tmp=10+chk(pts+1)+chk(pts+2); | |
| else | |
| if(tmp=chk(pts),a[++pts]=='/')tmp=10+chk(pts+1); | |
| else tmp+=chk(pts); | |
| printf("%d",ans+=tmp); | |
| if(i==9) putchar('\n');else putchar(' '); | |
| } | |
| int main() | |
| { | |
| while(1) | |
| { | |
| do a[++pts]=getchar(); | |
| while(getchar()!='\n'); | |
| printf("Case %d:\n",++k); | |
| for(pts=-1,ans=i=0;i<10;i++)cal(); | |
| a[pts=0]=getchar(); | |
| if(a[0]==EOF) break; | |
| getchar(); | |
| } | |
| return 0; | |
| } | 
  
    Sign up for free
    to join this conversation on GitHub.
    Already have an account?
    Sign in to comment