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

注意格式啊,每个图形完了要空一行!!贴代码!

Posted by 508618087 at 2012-02-29 00:09:44 on Problem 1102
#include <iostream>
#include <string>

using namespace std;
char ch[3][15]={"- -- -----","  ----- --","- -- -- --"};
char ch2[4][15]={"|   ||| ||","|||||  |||","| |   | | ","|| |||||||"};

void caculate(char n[10],int p,int s);
void sell(char n[10],int s,int p);
int main()
{
	int s,m=0;
	char n[10];
	while(cin>>s>>n)
	{
		if(s == 0 && strcmp(n,"0")==0 )	break;
		

		for(int i = 0; i< 2*s+3 ;i++)
		{
			if(i==0)
				caculate(n,0,s);

			 if(i==s+1)
				caculate(n,1,s);

			if(i==2*s+2)
				caculate(n,2,s);

			if(i>s+1&&i<2*s+2)
				sell(n,s,2);
			if(i<s+1&&i>0)
				sell(n,s,0);
			cout<<endl;
		}
		cout<<endl;
	}

	cout<<endl;
	return 0;
}

void caculate(char n[10],int p,int s)
{
	for(int i = 0; i< strlen(n); i++)
	{
		cout<<" ";
		for(int j = 0; j < s; j++)
			cout<< ch[p][n[i]-'0'];
		cout<<"  ";
	}
}

void sell(char n[10],int s,int p)
{
	for(int i = 0; i< strlen(n); i++)
	{
		cout<<ch2[p][n[i]-'0'];
		for(int j= 0; j<s; j++)
			cout<<" ";
		cout<<ch2[p+1][n[i]-'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