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 rudylau at 2008-07-23 10:21:00 on Problem 1102
#include<iostream>
#include<string>
using namespace std;
int main()
{
 int t;
 int l;
 char a[10];
 char b[100][100];
 int n;
 
 while(cin>>l>>a&&l&&a[0])
 {
  for(int q=0;q<=99;q++)
  {
   for(int w=0;w<=99;w++)
    b[q][w]=' ';
  }
  t=0;
  n=strlen(a);
  for(int i=1;i<=n;i++)
  {
   
   if(a[i-1]=='0')
   {
    for(int i=1;i<=l;i++)
    {
     b[0][t+i]='-';
     b[2*l+2][t+i]='-';
     b[i][t]='|';
     b[i+l+1][t]='|';
     b[i][t+l+1]='|';
     b[i+l+1][t+l+1]='|';
    }
   }
   if(a[i-1]=='1')
   {
    for(int i=1;i<=l;i++)
    {
     b[i][t+l+1]='|';
     b[i+l+1][t+l+1]='|';
    }
   }
   if(a[i-1]=='2')
   {
    for(int i=1;i<=l;i++)
    {
     b[0][t+i]='-';
     b[l+1][t+i]='-';
     b[2*l+2][t+i]='-';
     b[i+l+1][t]='|';
     b[i][t+l+1]='|';
    }
   }
   if(a[i-1]=='3')
   {
    for(int i=1;i<=l;i++)
    {
     b[0][t+i]='-';
     b[l+1][t+i]='-';
     b[2*l+2][t+i]='-';
     b[i][t+l+1]='|';
     b[i+l+1][t+l+1]='|';
    }
   }
   if(a[i-1]=='4')
   {
    for(int i=1;i<=l;i++)
    {
    b[l+1][t+i]='-';
    b[i][t]='|';
    b[i][t+l+1]='|';
    b[i+l+1][t+l+1]='|';
    }
   }
   if(a[i-1]=='5')
   {
    for(int i=1;i<=l;i++)
    {
     b[0][t+i]='-';
     b[l+1][t+i]='-';
     b[2*l+2][t+i]='-';
     b[i][t]='|';
     b[i+l+1][t+l+1]='|';
    }
   }
   if(a[i-1]=='6')
   {
    for(int i=1;i<=l;i++)
    {
     b[0][t+i]='-';
  
     b[l+1][t+i]='-';
 
     b[2*l+2][t+i]='-';
 
     b[i][t]='|';

     b[i+l+1][t]='|';
  
     b[i+l+1][t+l+1]='|';
    }
   }
   if(a[i-1]=='7')
   {
    for(int i=1;i<=l;i++)
    {
     b[0][t+i]='-';
 
     b[i][t+l+1]='|';
 
     b[i+l+1][t+l+1]='|';
    }
   }
   if(a[i-1]=='8')
   {
    for(int i=1;i<=l;i++)
    {
     b[0][t+i]='-';
     b[l+1][t+i]='-';
     b[2*l+2][t+i]='-';
     b[i][t]='|';
     b[i+l+1][t]='|';
     b[i][t+l+1]='|';
     b[i+l+1][t+l+1]='|';
    }
   }
   if(a[i-1]=='9')
   {
    for(int i=1;i<=l;i++)
    {
     b[0][t+i]='-';
     b[l+1][t+i]='-';
     b[2*l+2][t+i]='-';
     b[i][t]='|';
 
     b[i][t+l+1]='|';
     b[i+l+1][t+l+1]='|';
    }
   }
   t=(l+3)*i;
  }
  for(int j=0;j<=2*l+2;j++)
  {
   for(int k=0;k<=(l+3)*n;k++)
    cout<<b[j][k];
   cout<<endl;
  }
  cout<<endl;
 }
 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