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

AC

Posted by guxiguxi at 2017-11-07 10:28:57 on Problem 1076
#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:
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