POJ 2745 显示器 解题报告
POJ 2745 显示器 解题报告
编号:2745
考查点:模拟
思路:抽象出来,计算器显示是7个笔画,然后建立数组表示各笔画被覆盖情况,不过这个是我看了书之后实现的,方法果真经典.
提交情况:比较顺利,自己debug完之后,一次就AC了,1000K,0MS..
Source Code:
//POJ Grids 2745
#include <iostream>
using namespace std;
char n1[] = "- -- -----";
char n2[] = "| ||| ||";
char n3[] = "||||| |||";
char n4[] = " ----- --";
char n5[] = "| | | | ";
char n6[] = "|| |||||||";
char n7[] = "- -- -- --";
int main()
{
int m;
char n[10];
cin>>m>>n;
while ((n[0]-'0')||m)
{
int len = strlen(n);
for (int i=0;i<len;i++)
{
cout<<" ";
int num = n[i]-'0';
for (int j=0;j<m;j++)
{
cout<<n1[num];
}
cout<<" ";
}
cout<<endl;
int temp = m;
while (temp--)
{
for (int i=0;i<len;i++)
{
int num = n[i]-'0';
cout<<n2[num];
for (int j=0;j<m;j++)
{
cout<<" ";
}
cout<<n3[num];
cout<<" ";
}
cout<<endl;
}
for (int i=0;i<len;i++)
{
cout<<" ";
int num = n[i]-'0';
for (int j=0;j<m;j++)
{
cout<<n4[num];
}
cout<<" ";
}
cout<<endl;
temp = m;
while (temp--)
{
for (int i=0;i<len;i++)
{
int num = n[i]-'0';
cout<<n5[num];
for (int j=0;j<m;j++)
{
cout<<" ";
}
cout<<n6[num];
cout<<" ";
}
cout<<endl;
}
for (int i=0;i<len;i++)
{
cout<<" ";
int num = n[i]-'0';
for (int j=0;j<m;j++)
{
cout<<n7[num];
}
cout<<" ";
}
cout<<endl<<endl;
cin>>m>>n;
}
return 0;
}
总结:总结发现,一般显示复杂的题只要实现了sample output一般不会出现太多的意外,如果是和显示关系不大的题很容易判断情况不周全,导致一直WA..
By Ns517
Time