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 |
AC#include <stdio.h> int main(int argc, char *argv[]) { char name[25]; int number, r[25], score[20]; while(scanf("%s", name) > 0) { int k = 0, c = 0; while(scanf("%d", &number) && number != -1) { r[k++] = number; } printf("%-12s", name); for(int i = 0; i < k; ++i) { if(c++ < 10) printf(" "); score[c] = 0; if(r[i] == 0) { if(i + 1 < k && c < 10) printf("X "); else printf("X"); if(i + 2 < k) { if(r[i + 1] == 0) score[c] = 10 + 10 + 10 - r[i + 2]; else score[c] = 10 + 10 - r[i + 2]; } else score[c] = -1; } else { if(r[i] == 10) printf("-"); else printf("%d", 10 - r[i]); if(i + 1 < k){ if(r[i + 1] == 0) { printf("/"); if(i + 2 < k) score[c] = 10 + 10 - r[i + 2]; else score[c] = -1; } else if(r[i] == r[i + 1]) { score[c] = 10 - r[i]; printf("-"); } else { score[c] = 10 - r[i + 1]; printf("%d", r[i] - r[i + 1]); } } else score[c] = -1; if(i + 2 < k && c < 10) printf(" "); ++i; } } printf("\n "); int total = 0; for(int i = 1; i <= c; ++i) { if(score[i] == -1) break; total += score[i]; printf(" %3d", total); } printf("\n\n"); } return 0; } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator