| ||||||||||
| 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 <string>
using namespace std;
void process(int s,long n)
{
int i,k,m;
int a[8];
string str1,str2;
string str3=" ";
str1="-";
str2=" ";
if(s==0||n==0)
return ;
i=0;
while(n!=0)
{
a[i]=n%10;
n=n/10;
i++;
}
for(k=s-1;k>0;k--)
{
str1=str1+"-";
str2=str2+" ";
}
for(m=i-1;m>=0;m--) //输出第一行
{
switch(a[m])
{
case 1:
case 4:cout<<str3<<str2<<str3;
break;
case 0:
case 2:
case 3:
case 5:
case 6:
case 7:
case 8:
case 9:cout<<str3<<str1<<str3;
break;
}
if(m!=0)
cout<<str3;
}
cout<<endl;
for(k=1;k<=s;k++) //输出第二行
{
for(m=i-1;m>=0;m--)
{
switch(a[m])
{
case 1:
case 2:
case 3:
case 7:cout<<str3<<str2<<"|";
break;
case 4:
case 0:
case 8:
case 9:cout<<"|"<<str2<<"|";
break;
case 5:
case 6:cout<<"|"<<str2<<str3;
break;
}
if(m!=0)
cout<<str3;
}
cout<<endl;
}
for(m=i-1;m>=0;m--) //输出第三行
{
switch(a[m])
{
case 0:
case 1:
case 7:cout<<str3<<str2<<str3;
break;
case 2:
case 3:
case 4:
case 5:
case 6:
case 8:
case 9:cout<<str3<<str1<<str3;
break;
}
if(m!=0)
cout<<str3;
}
cout<<endl;
for(k=1;k<=s;k++) //输出第si行
{
for(m=i-1;m>=0;m--)
{
switch(a[m])
{
case 1:
case 3:
case 4:
case 5:
case 7:
case 9:cout<<" "<<str2<<"|";
break;
case 2:cout<<"|"<<str2<<" ";
break;
case 6:
case 8:
case 0:cout<<"|"<<str2<<"|";
break;
}
if(m!=0)
cout<<str3;
}
cout<<endl;
}
for(m=i-1;m>=0;m--)
{
switch(a[m])
{
case 1:
case 4:
case 7:cout<<str3<<str2<<str3;
break;
case 0:
case 2:
case 3:
case 5:
case 6:
case 8:
case 9:cout<<str3<<str1<<str3;
break;
}
if(m!=0)
cout<<str3;
}
cout<<endl;
return ;
}
int main()
{
int s;
long n;
cin>>s>>n;
while(s!=0&&n!=0L)
{
process(s,n);
cin>>s>>n;
}
return 0;
}
Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator