P5730
这道题莫名其妙的在本地能过可是洛谷上却0分,把WA的点下载下来之后发现我输出的和他要输出的明明一模一样,说明洛谷的评测有一些问题。我把getchar输入换成cin输入后就AC了,说明洛谷对getchar的处理和我本地VScode的处理不一样,总结就是下次慎用getchar这种啥都输入的东西。
WA-Code(AC-Code在后面)
#include <iostream>
#include <string>
using namespace std;
int n,num[105];
string no[10][5]={
"XXX","X.X","X.X","X.X","XXX",
"..X","..X","..X","..X","..X",
"XXX","..X","XXX","X..","XXX",
"XXX","..X","XXX","..X","XXX",
"X.X","X.X","XXX","..X","..X",
"XXX","X..","XXX","..X","XXX",
"XXX","X..","XXX","X.X","XXX",
"XXX","..X","..X","..X","..X",
"XXX","X.X","XXX","X.X","XXX",
"XXX","X.X","XXX","..X","XXX"
};
int main()
{
scanf("%d",&n);getchar();//while(getchar()==' ');
for(int i=1;i<=n;i++)num[i]=int(getchar()-'0');//while(getchar()==' ');
for(int i=0;i<5;i++)
{
for(int j=1;j<=n;j++)
{
cout<<no[num[j]][i];
if(j!=n)cout<<'.';
}
if(i!=4)cout<<endl;
}
cout<<endl;
return 0;
}
AC-Code
#include <iostream>
#include <string>
using namespace std;
int n,num[105];
string no[10][5]={
"XXX","X.X","X.X","X.X","XXX",
"..X","..X","..X","..X","..X",
"XXX","..X","XXX","X..","XXX",
"XXX","..X","XXX","..X","XXX",
"X.X","X.X","XXX","..X","..X",
"XXX","X..","XXX","..X","XXX",
"XXX","X..","XXX","X.X","XXX",
"XXX","..X","..X","..X","..X",
"XXX","X.X","XXX","X.X","XXX",
"XXX","X.X","XXX","..X","XXX"
};
int main()
{
scanf("%d",&n);
char c;
for(int i=1;i<=n;i++)
{
cin>>c;
num[i]=int(c-'0');
}
for(int i=0;i<5;i++)
{
for(int j=1;j<=n;j++)
{
cout<<no[num[j]][i];
if(j!=n)cout<<'.';
}
if(i!=4)cout<<endl;
}
cout<<endl;
return 0;
}