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呢!!!!连n=0都考虑了阿!!没错啊!

Posted by liao14 at 2007-09-10 10:10:06 on Problem 1102
/*代码比较难看,见谅!*/

#include<iostream>
#include<algorithm>

using namespace std;

char b[30][150];
int n,s;
int l;

void zero()
{
	int i;
	l++;
	for(i=l+1;i<l+s+1;i++) b[0][i]='-',b[2*s+2][i]='-';
	for(i=1;i<2*s+2;i++) 
		if(i!=1+s)b[i][l]='|',b[i][l+s+1]='|';
	l+=s+2;
}

void one()
{
	int i;
	
	l++;
	for(i=1;i<2*s+2;i++) 
		if(i!=1+s) 
			b[i][l+s+1]='|';

	l+=s+2;
}

void two()
{
	int i;
	l++;
	for(i=l+1;i<l+s+1;i++) b[0][i]='-',b[2*s+2][i]='-',b[1+s][i]='-';
	for(i=1;i<1+s;i++) 
		b[i][l+s+1]='|';
	for(i=2+s;i<2*s+2;i++) 
		if(i!=1+s)b[i][l]='|';	
	l+=s+2;
}

void three()
{
	int i;
	l++;
	for(i=l+1;i<l+s+1;i++) b[0][i]='-',b[2*s+2][i]='-',b[1+s][i]='-';
	for(i=1;i<2*s+2;i++) 
		b[i][l+s+1]='|';	
	l+=s+2;
}

void four()
{
	int i;
	l++;
	for(i=l+1;i<l+s+1;i++) b[1+s][i]='-';
	for(i=1;i<2*s+2;i++) 
		if(i!=1+s)b[i][l+s+1]='|';
	for(i=1;i<1+s;i++) 
		b[i][l]='|';	
	l+=s+2;
}

void five()
{
	int i;
	l++;
	for(i=l+1;i<l+s+1;i++) b[0][i]='-',b[2*s+2][i]='-',b[1+s][i]='-';
	for(i=1+1+s;i<2*s+2;i++) 
		b[i][l+s+1]='|';
	for(i=1;i<1+s;i++) 
		b[i][l]='|';	
	l+=s+2;
}

void six()
{
	int i;
	l++;
	for(i=l+1;i<l+s+1;i++) b[0][i]='-',b[2*s+2][i]='-',b[1+s][i]='-';
	for(i=1+1+s;i<2*s+2;i++) 
		b[i][l+s+1]='|';
	for(i=1;i<2*s+2;i++) 
		if(i!=1+s)b[i][l]='|';	
	l+=s+2;
}

void seven()
{
	int i;	
	l++;
	for(i=l+1;i<l+s+1;i++) b[0][i]='-';
	for(i=1;i<2*s+2;i++) 
		if(i!=1+s) b[i][l+s+1]='|';
	l+=s+2;
}

void eight()
{
	int i;
	l++;
	for(i=l+1;i<l+s+1;i++) b[0][i]='-',b[2*s+2][i]='-',b[1+s][i]='-';
	for(i=1;i<2*s+2;i++) 
		if(i!=1+s)b[i][l+s+1]='|';
	for(i=1;i<2*s+2;i++) 
		if(i!=1+s)b[i][l]='|';	
	l+=s+2;
}

void nine()
{
	int i;
	l++;
	for(i=l+1;i<l+s+1;i++) b[0][i]='-',b[2*s+2][i]='-',b[1+s][i]='-';
	for(i=1;i<2*s+2;i++) 
		if(i!=1+s)b[i][l+s+1]='|';
	for(i=1;i<1+s;i++) 
		b[i][l]='|';	
	l+=s+2;
}

int main()
{
	long num,m;
	int i,j;
	int aa[9];
	//freopen("out.txt","w",stdout);
	while(1)
	{
		scanf("%ld%ld",&s,&num);
		if(!s) break;
		memset(b,' ',sizeof b);
		m=0;
		while(num>0)
		{
			aa[m++]=num%10;
			num/=10;
		}
		if(m==0) m=1,aa[0]=0;
		n=0;
		l=0;
		do
		{	
			m--;		
			switch(aa[m])
			{
				case 0:zero();break;
				case 1:one();break;
				case 2:two();break;
				case 3:three();break;
				case 4:four();break;
				case 5:five();break;
				case 6:six();break;
				case 7:seven();break;
				case 8:eight();break;
				case 9:nine();break;
			}
			n++;				
		}while(m>0);

		for(i=0;i<2*s+3;i++,putchar('\n'))
			for(j=1;j<=n*(s+2)+n-1;j++) putchar(b[i][j]);
		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