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 291547564 at 2012-01-23 17:10:44 on Problem 1102
#include<iostream>
using namespace std;
int main()
{
	int s,n,i,j,k,m[8],count;
	while(cin>>s>>n)
	{
		if(s==0&&n==0)
			continue;
		i=0;
		count=0;
		while(n!=0)
		{
			count++;
			m[i]=n%10;
			n=n/10;
			i++;
		}
		for(i=count-1;i>=0;i--)
		{
			if(m[i]==1||m[i]==4)
			{
				cout<<"    ";
				for(j=s-2;j>=0;j--)
					cout<<" ";
			}
			else
			{
				cout<<" -";
				for(j=s-2;j>=0;j--)
					cout<<"-";
				cout<<"  ";
			}
		}
		cout<<endl;
		for(k=1;k<=s;k++)
		{
			for(i=count-1;i>=0;i--)
			{

				if(m[i]==1||m[i]==2||m[i]==3||m[i]==7)
				{
					cout<<"  ";
		    		for(j=s-2;j>=0;j--)
					cout<<" ";
				}
				else
				{
					cout<<"| ";
					for(j=s-2;j>=0;j--)
						cout<<" ";
				}
				if(m[i]==5||m[i]==6)
					cout<<"  ";
				else
					cout<<"| ";
			}
			cout<<endl;
		}
		for(i=count-1;i>=0;i--)
		{
			if(m[i]==1||m[i]==7||m[i]==0)
			{
				cout<<"    ";
				for(j=s-2;j>=0;j--)
					cout<<" ";
			}
			else
			{
				cout<<" -";
				for(j=s-2;j>=0;j--)
					cout<<"-";
				cout<<"  ";
			}
		}
		cout<<endl;
		for(k=1;k<=s;k++)
		{
   			for(i=count-1;i>=0;i--)
			{
					if(m[i]==2||m[i]==6||m[i]==8||m[i]==0)
					{
            			cout<<"| ";				
		    			for(j=s-2;j>=0;j--)
						cout<<" ";
					}
					else
					{
						cout<<"  ";
						for(j=s-2;j>=0;j--)
							cout<<" ";
					}
					if(m[i]==2)
						cout<<"  ";
					else
						cout<<"| ";
			}	
			cout<<endl;
		}
		for(i=count-1;i>=0;i--)
		{
			if(m[i]==1||m[i]==4||m[i]==7)
			{
				cout<<"    ";
				for(j=s-2;j>=0;j--)
					cout<<" ";
			}
			else
			{
				cout<<" -";
				for(j=s-2;j>=0;j--)
					cout<<"-";
				cout<<"  ";
			}
		}
		cout<<endl<<endl;
	}
}

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