| ||||||||||
| Online Judge | Problem Set | Authors | Online Contests | User | ||||||
|---|---|---|---|---|---|---|---|---|---|---|
| Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest | |||||||||
此题咋说好哪位兄弟帮看下,本地上没有了错误了阿,怎么弄上来就是WA,格式有何问题。
#include <iostream>
#include <vector>
#include <string.h>
using namespace std;
int code[10][7] ={{1,2,2,0,2,2,1},{0,0,2,0,0,2,0},{1,0,2,1,2,0,1},
{1,0,2,1,0,2,1},{0,2,2,1,0,2,0},{1,2,0,1,0,2,1},
{1,2,0,1,2,2,1},{1,0,2,0,0,2,0},{1,2,2,1,2,2,1},
{1,2,2,1,0,2,1}};
void print(const char* buf, int s,int digits);
int main()
{
//cout << "Hello world!" << endl;
//vector<int>* num = new vector<int>(5);
//vector<int>* size = new vector<int>(5);
string* num = new string[1000000];
int* size = new int[1000000];
int s;
string n;
int count = 0;
cin>>s;
cin>>n;
while(s != 0 && n !="0")
{
size[count] = s;
//cin>>n;
num[count] = n;
count++;
cin>>s;
cin>>n;
}
int i=0;
while(i<count)
{
s = size[i];
//size.pop_front();
n = num[i];
//num.pop_front();
const char* buf = n.c_str();
int digits = strlen(buf);
print(buf,s,digits);
if(i<count-1)
{
cout<<'\n';
//cout<<endl;
}
i++;
}
//print(1234567890,1);ŚŚŚ
delete[] num;
delete[] size;
return 0;
}
void print(const char* buf, const int s,const int digits)
{
for(int r=0;r<5;r++)
{
if(r ==1 || r == 3)
for(int ss=0;ss<s;ss++)
{
for(int d=0;d<digits;d++)
{
if(d!=0) cout<<" ";
if(r==1)
{
if(code[buf[d]-'0'][1]==0) cout<<" ";
if(code[buf[d]-'0'][1]==1) cout<<"-";
if(code[buf[d]-'0'][1]==2) cout<<"|";
for(int i=0;i<s;i++) cout<<" ";
if(code[buf[d]-'0'][2]==0) cout<<" ";
if(code[buf[d]-'0'][2]==1) cout<<"-";
if(code[buf[d]-'0'][2]==2) cout<<"|";
}
if(r==3)
{
if(code[buf[d]-'0'][4]==0) cout<<" ";
if(code[buf[d]-'0'][4]==1) cout<<"-";
if(code[buf[d]-'0'][4]==2) cout<<"|";
for(int i=0;i<s;i++) cout<<" ";
if(code[buf[d]-'0'][5]==0) cout<<" ";
if(code[buf[d]-'0'][5]==1) cout<<"-";
if(code[buf[d]-'0'][5]==2) cout<<"|";
}
}
if(ss<s-1)
cout<<'\n';
}
else
for(int d=0;d<digits;d++)
{
if(r==0)
{
if(d!=0) cout<<" ";
if(d==0) cout<<" ";
for(int i=0;i<s;i++)
{
if(code[buf[d]-'0'][0] == 0)
cout<<" ";
else if(code[buf[d]-'0'][0] == 1)
cout<<"-";
else if(code[buf[d]-'0'][0] == 2)
cout<<"|";
}
cout<<" ";
}
if(r==2)
{
if(d!=0) cout<<" ";
if(d==0) cout<<" ";
for(int i=0;i<s;i++)
{
if(code[buf[d]-'0'][3] == 0)
cout<<" ";
else if(code[buf[d]-'0'][3] == 1)
cout<<"-";
else if(code[buf[d]-'0'][3] == 2)
cout<<"|";
}
cout<<" ";
}
if(r==4)
{
if(d!=0) cout<<" ";
if(d==0) cout<<" ";
for(int i=0;i<s;i++)
{
if(code[buf[d]-'0'][6] == 0)
cout<<" ";
else if(code[buf[d]-'0'][6] == 1)
cout<<"-";
else if(code[buf[d]-'0'][6] == 2)
cout<<"|";
}
cout<<" ";
}
}
cout<<'\n';
}
}
Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator