社区讨论

求助,c++明明本地输出全对,但全红

P5730【深基5.例10】显示屏参与者 2已保存回复 2

讨论操作

快速查看讨论及其快照的属性,并进行相关操作。

当前回复
2 条
当前快照
1 份
快照标识符
@m3939m12
此快照首次捕获于
2024/11/09 02:47
去年
此快照最后确认于
2025/11/04 15:05
4 个月前
查看原帖
CPP
#include<iostream>
#include <string>
using namespace std;

string x__ = "x..";
string x_x = "x.x";
string xxx = "xxx";
string __x = "..x";

string a1[5] = { __x,__x,__x,__x,__x };
string a2[5] = { xxx,__x,xxx,x__,xxx };
string a3[5] = { xxx,__x,xxx,__x,xxx };
string a4[5] = { x_x,x_x,xxx,__x,__x };
string a5[5] = { xxx,x__,xxx,__x,xxx };
string a6[5] = { xxx,x__,xxx,x_x,xxx };
string a7[5] = { xxx,__x,__x,__x,__x };
string a8[5] = { xxx,x_x,xxx,x_x,xxx };
string a9[5] = { xxx,x_x,xxx,__x,xxx };
string a0[5] = { xxx,x_x,x_x,x_x,xxx };

int main()
{
	int a;
	string sh;
	cin >> a;
	int* s = new int[a];
	cin >> sh;
	char *b = new char[a];
	for (int i = 0; i < a; i++)
	{
		b[i] = sh[i];
		s[i] = sh[i] - '0';
	}
	for (int i = 0; i < 5; i++)
	{
		for (int z = 0; z < a; z++)
		{
			switch (s[z])
			{
			case 1:cout << a1[i];
				break;
			case 2:cout << a2[i];
				break;
			case 3:cout << a3[i];
				break;
			case 4:cout << a4[i];
				break;
			case 5:cout << a5[i];
				break;
			case 6:cout << a6[i];
				break;
			case 7:cout << a7[i];
				break;
			case 8:cout << a8[i];
				break;
			case 9:cout << a9[i];
				break;
			case 0:cout << a0[i];
				break;
			}
			if (z != a - 1)
			{
				cout << ".";
			}
		}
		cout << endl;
	}

}

回复

2 条回复,欢迎继续交流。

正在加载回复...