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 zzyzzy12 at 2010-08-13 20:48:05 on Problem 1102
#include<iostream>
#include<string>
#include<fstream>
using namespace std;
// ofstream fout("1.txt");
string str;
int s,k,p,i,j;
char map[301][301];
int main()
{
 cin>>s>>str;
 while (s!=0)
 {
  k=1;
  for (i=1;i<=100;i++) for (j=1;j<=100;j++) map[i][j]=' ';     
  for (p=0;p<str.length();p++) 
   {
     if (str[p]=='1')  
      { 
       for (i=2;i<=1+s;i++) map[i][k+s+1]='|';
       for (i=3+s;i<=2*s+2;i++) map[i][k+s+1]='|';
                        } else
     if (str[p]=='2')  
     {  
       for (i=k+1;i<=k+s;i++) map[1][i]='-'; 
       for (i=2;i<=1+s;i++) map[i][k+s+1]='|';  
       for (i=k+1;i<=k+s;i++) map[2+s][i]='-'; 
       for (i=3+s;i<=2*s+2;i++) map[i][k]='|';
       for (i=k+1;i<=k+s;i++) map[2*s+3][i]='-';           
                       } else                         
     if (str[p]=='3')  
     { 
       for (i=k+1;i<=k+s;i++) map[1][i]='-'; 
       for (i=2;i<=1+s;i++) map[i][k+s+1]='|';  
       for (i=k+1;i<=k+s;i++) map[2+s][i]='-'; 
       for (i=3+s;i<=2*s+2;i++) map[i][k+s+1]='|';
       for (i=k+1;i<=k+s;i++) map[2*s+3][i]='-';                
                        } else
     if (str[p]=='4')  
     { 
       for (i=2;i<=1+s;i++) map[i][k]='|'; 
       for (i=2;i<=1+s;i++) map[i][k+s+1]='|';  
       for (i=k+1;i<=k+s;i++) map[2+s][i]='-'; 
       for (i=3+s;i<=2*s+2;i++) map[i][k+s+1]='|';        } else
     if (str[p]=='5')  
     { 
       for (i=k+1;i<=k+s;i++) map[1][i]='-'; 
       for (i=2;i<=1+s;i++) map[i][k]='|';  
       for (i=k+1;i<=k+s;i++) map[2+s][i]='-'; 
       for (i=3+s;i<=2*s+2;i++) map[i][k+s+1]='|';
       for (i=k+1;i<=k+s;i++) map[2*s+3][i]='-';     } else
     if (str[p]=='6') 
      {for (i=k+1;i<=k+s;i++) map[1][i]='-'; 
       for (i=2;i<=1+s;i++) map[i][k]='|';  
       for (i=k+1;i<=k+s;i++) map[2+s][i]='-'; 
       for (i=3+s;i<=2*s+2;i++) map[i][k+s+1]='|';
       for (i=3+s;i<=2*s+2;i++) map[i][k]='|';
       for (i=k+1;i<=k+s;i++) map[2*s+3][i]='-';      } else
     if (str[p]=='7')  
      {
       for (i=k+1;i<=k+s;i++) map[1][i]='-'; 
       for (i=2;i<=1+s;i++) map[i][k+s+1]='|';  
       for (i=3+s;i<=2*s+2;i++) map[i][k+s+1]='|';
                   } else
     if (str[p]=='8')  
      {
       for (i=k+1;i<=k+s;i++) map[1][i]='-'; 
       for (i=2;i<=1+s;i++) map[i][k]='|'; 
       for (i=2;i<=1+s;i++) map[i][k+s+1]='|';  
       for (i=k+1;i<=k+s;i++) map[2+s][i]='-'; 
       for (i=3+s;i<=2*s+2;i++) map[i][k+s+1]='|';
       for (i=3+s;i<=2*s+2;i++) map[i][k]='|';
       for (i=k+1;i<=k+s;i++) map[2*s+3][i]='-';         } else
     if (str[p]=='9') 
      {for (i=k+1;i<=k+s;i++) map[1][i]='-'; 
       for (i=2;i<=1+s;i++) map[i][k]='|'; 
       for (i=2;i<=1+s;i++) map[i][k+s+1]='|';  
       for (i=k+1;i<=k+s;i++) map[2+s][i]='-'; 
       for (i=3+s;i<=2*s+2;i++) map[i][k+s+1]='|';
       for (i=k+1;i<=k+s;i++) map[2*s+3][i]='-';    } else
     {
       for (i=k+1;i<=k+s;i++) map[1][i]='-'; 
       for (i=2;i<=1+s;i++) map[i][k]='|'; 
       for (i=2;i<=1+s;i++) map[i][k+s+1]='|';  
       for (i=3+s;i<=2*s+2;i++) map[i][k+s+1]='|';
       for (i=3+s;i<=2*s+2;i++) map[i][k]='|';
       for (i=k+1;i<=k+s;i++) map[2*s+3][i]='-';          }
     k=k+s+3;         }    
  k=k-2;  
  for (i=1;i<=2*s+3;i++) 
   { for (j=1;j<=k;j++) cout<<map[i][j];
     cout<<endl;  } 
  cout<<endl;
  cin>>s>>str;    }       
 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