首页 > 其他分享 >P5730

P5730

时间:2023-10-11 10:22:10浏览次数:27  
标签:P5730 .. int XXX num include getchar

这道题莫名其妙的在本地能过可是洛谷上却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;
}

标签:P5730,..,int,XXX,num,include,getchar
From: https://www.cnblogs.com/gongkai/p/17756431.html

相关文章

  • P5730
    LuoguP5730【深基5.例10】显示屏题解一道相当具有代表性的题目的解析题面【深基5.例10】显示屏题目描述液晶屏上,每个阿拉伯数字都是可以显示成\(3\times5\)......
  • P5730 【深基5.例10】显示屏 洛谷
    #include<stdio.h>intmain(){charstr1[30]="XXX..XXXXXXXX.XXXXXXXXXXXXXXXX";charstr2[30]="X.X..X..X..XX.XX..X....XX.XX.X";charstr3[30]="X.......