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:求解各位大神~~~~~~为何wa?附代码

Posted by 1023015455 at 2012-03-07 22:49:12 on Problem 1102
In Reply To:求解各位大神~~~~~~为何wa?附代码 Posted by:jsyzchenjc at 2012-03-07 22:23:53
> #include<stdio.h>
> #include<string.h>
> 
> void translate(char *str,int n){
> 	char print[1000][1000];
> 	int i,j,k;
> 	for(k = 0; k < (int )strlen(str); k++)
> 	{
> 		switch(str[k])
> 		{
> 		case '1':
> 			for(i = 1; i <= n ; i++ )
> 			{
> 				print[i][(n+3)*k+n+1] = '|';print[i+n+1][(n+3)*k+n+1] = '|';
> 			}break;
> 		case '2':
> 			for(i = 1; i <= n ; i++ )
> 			{
> 				print[0][(n+3)*k+i] = '-';print[n+1][(n+3)*k+i] = '-';print[2*n+2][(n+3)*k+i] = '-';
> 				print[n+1+i][(n+3)*k+0] = '|';print[i][(n+3)*k+n+1] = '|';
> 			}break;
> 		case '3':
> 			for(i = 1; i <= n ; i++ )
> 			{
> 				print[0][(n+3)*k+i] = '-';print[n+1][(n+3)*k+i] = '-';print[2*n+2][(n+3)*k+i] = '-';
> 				print[n+1+i][(n+3)*k+n+1] = '|';print[i][(n+3)*k+n+1] = '|';
> 			}break;
> 		case '4':
> 			for(i = 1; i <= n ; i++ )
> 			{
> 				print[n+1][(n+3)*k+i] = '-';
> 				print[n+1+i][(n+3)*k+n+1] = '|';print[i][(n+3)*k+n+1] = '|';print[i][(n+3)*k+0] = '|';
> 			}break;
> 		case '5':
> 			for(i = 1; i <= n ; i++ )
> 			{
> 				print[0][(n+3)*k+i] = '-';print[n+1][(n+3)*k+i] = '-';print[2*n+2][(n+3)*k+i] = '-';
> 				print[n+1+i][(n+3)*k+n+1] = '|';print[i][(n+3)*k+0] = '|';
> 			}break;
> 		case '6':
> 			for(i = 1; i <= n ; i++ )
> 			{
> 				print[0][(n+3)*k+i] = '-';print[n+1][(n+3)*k+i] = '-';print[2*n+2][(n+3)*k+i] = '-';
> 				print[n+1+i][(n+3)*k+n+1] = '|';print[i][(n+3)*k+0] = '|';print[n+1+i][(n+3)*k+0] = '|';
> 			}break;
> 		case '7':
> 			for(i = 1; i <= n ; i++ )
> 			{
> 				print[0][(n+3)*k+i] = '-';
> 				print[i][(n+3)*k+n+1] = '|';print[i+n+1][(n+3)*k+n+1] = '|';
> 			}break;
> 		case '8':
> 			for(i = 1; i <= n ; i++ )
> 			{
> 				print[0][(n+3)*k+i] = '-';print[n+1][(n+3)*k+i] = '-';print[2*n+2][(n+3)*k+i] = '-';
> 				print[n+1+i][(n+3)*k+n+1] = '|';print[i][(n+3)*k+0] = '|';print[n+1+i][(n+3)*k+0] = '|';print[i][(n+3)*k+n+1] = '|';
> 			}break;
> 		case '9':
> 			for(i = 1; i <= n ; i++ )
> 			{
> 				print[0][(n+3)*k+i] = '-';print[n+1][(n+3)*k+i] = '-';print[2*n+2][(n+3)*k+i] = '-';
> 				print[n+1+i][(n+3)*k+n+1] = '|';print[i][(n+3)*k+0] = '|';print[i][(n+3)*k+n+1] = '|';
> 			}break;
> 		case '0':
> 			for( i = 1; i <= n ; i++ )
> 			{
> 				print[0][(n+3)*k+i] = '-';print[2*n+2][(n+3)*k+i] = '-';
> 				print[n+1+i][(n+3)*k+n+1] = '|';print[i][(n+3)*k+0] = '|';print[n+1+i][(n+3)*k+0] = '|';print[i][(n+3)*k+n+1] = '|';
> 			}break;
> 		}
> 	}
> 
> 	for( i = 0; i < 2*n+3; i++ )
> 	{ 
> 		for( j = 0; j < ((n+3)*k+1) ; j++ )
> 		{
> 			if(print[i][j] != '|' && print[i][j] != '-')
> 				printf(" ");
> 			else
> 				printf("%c",print[i][j]);
> 		}
> 		printf("\n");
> 	}
> 
> }
> 
> 
> int main()
> {
> 	char a[15];
> 	int n;
> 	while(scanf("%d %s",&n,a),a[0]!='0'||n)
> 	{
> 		if(n==0)printf("\n");
> 		else
> 		{
> 			translate(a,n);
> 			printf("\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