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

一直WA,但是样例都对,求大牛指点一下

Posted by kuaichenyang at 2015-04-24 16:29:09 on Problem 1102
#include <stdio.h>
#include <string.h>

void main()
{
	int s;
	char digit[150];
	while(scanf("%d%s",&s,digit),s&&strcmp("0",digit))
	{
		int i,w;
		int len=strlen(digit);
		//1
		for(i=0;i<len;i++)
		{
			if(digit[i]=='0'||digit[i]=='2'||digit[i]=='3'||digit[i]=='5'||digit[i]=='6'||digit[i]=='7'||digit[i]=='8'||digit[i]=='9')
			{
				int j;
				putchar(' ');
				for(j=1;j<=s;j++)
					putchar('-');
				putchar(' ');
			}
			else if(digit[i]=='1'||digit[i]=='4')
			{
				int j;
				for(j=1;j<=s+2;j++)
					putchar(' ');
			}
			if(digit[i+1]!='\0')
				putchar(' ');
		}
		printf("\n");
		
		//2
		for(w=1;w<=s;w++)
		{
			for(i=0;i<len;i++)
			{
				int j;
				if(digit[i]=='0'||digit[i]=='4'||digit[i]=='5'||digit[i]=='6'||digit[i]=='8'||digit[i]=='9')
					putchar('|');
				else if(digit[i]=='1'||digit[i]=='2'||digit[i]=='3'||digit[i]=='7')
					putchar(' ');
				for(j=1;j<=s;j++)
					putchar(' ');
				if(digit[i]=='5'||digit[i]=='6')
					putchar(' ');
				else if(digit[i]=='0'||digit[i]=='1'||digit[i]=='2'||digit[i]=='3'||digit[i]=='4'||digit[i]=='7'||digit[i]=='8'||digit[i]=='9')
					putchar('|');
				if(digit[i+1]!='\0')
					putchar(' ');
			}
			printf("\n");
		}

		//3
		for(i=0;i<len;i++)
		{
			if(digit[i]=='2'||digit[i]=='3'||digit[i]=='4'||digit[i]=='5'||digit[i]=='6'||digit[i]=='8'||digit[i]=='9')
			{
				int j;
				putchar(' ');
				for(j=1;j<=s;j++)
					putchar('-');
				putchar(' ');
			}
			else if(digit[i]=='0'||digit[i]=='1'||digit[i]=='7')
			{
				int j;
				for(j=1;j<=s+2;j++)
					putchar(' ');
			}
			if(digit[i+1]!='\0')
				putchar(' ');
		}
		printf("\n");

		//4
		for(w=1;w<=s;w++)
		{
			for(i=0;i<len;i++)
			{
				int j;
				if(digit[i]=='1'||digit[i]=='3'||digit[i]=='4'||digit[i]=='5'||digit[i]=='7'||digit[i]=='9')
					putchar(' ');
				else if(digit[i]=='0'||digit[i]=='2'||digit[i]=='6'||digit[i]=='8')
					putchar('|');
				for(j=1;j<=s;j++)
					putchar(' ');
				if(digit[i]=='2')
					putchar(' ');
				else if(digit[i]=='0'||digit[i]=='1'||digit[i]=='3'||digit[i]=='4'||digit[i]=='5'||digit[i]=='6'||digit[i]=='7'||digit[i]=='8'||digit[i]=='9')
					putchar('|');
				if(digit[i+1]!='\0')
					putchar(' ');
			}
			printf("\n");
		}

		//5
		for(i=0;i<len;i++)
		{
			if(digit[i]=='0'||digit[i]=='2'||digit[i]=='3'||digit[i]=='5'||digit[i]=='6'||digit[i]=='8'||digit[i]=='9')
			{
				int j;
				putchar(' ');
				for(j=1;j<=s;j++)
					putchar('-');
				putchar(' ');
			}
			else if(digit[i]=='1'||digit[i]=='4'||digit[i]=='7')
			{
				int j;
				for(j=1;j<=s+2;j++)
					putchar(' ');
			}
			if(digit[i+1]!='\0')
				putchar(' ');
		}
		printf("\n");
		printf("\n");
	}
}

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