全部评论
真的mmp
2333 开天辟地 String[][] ea = new String[10][5];
void init() {
ea[0][0] = "66666";
ea[0][1] = "6...6";
ea[0][2] = "6...6";
ea[0][3] = "6...6";
ea[0][4] = "66666";
ea[1][0] = "....6";
ea[1][1] = "....6";
ea[1][2] = "....6";
ea[1][3] = "....6";
ea[1][4] = "....6";
ea[2][0] = "66666";
ea[2][1] = "....6";
ea[2][2] = "66666";
ea[2][3] = "6....";
ea[2][4] = "66666";
ea[3][0] = "66666";
ea[3][1] = "....6";
ea[3][2] = "66666";
ea[3][3] = "....6";
ea[3][4] = "66666";
ea[4][0] = "6...6";
ea[4][1] = "6...6";
ea[4][2] = "66666";
ea[4][3] = "....6";
ea[4][4] = "....6";
ea[5][0] = "66666";
ea[5][1] = "6....";
ea[5][2] = "66666";
ea[5][3] = "....6";
ea[5][4] = "66666";
ea[6][0] = "66666";
ea[6][1] = "6....";
ea[6][2] = "66666";
ea[6][3] = "6...6";
ea[6][4] = "66666";
ea[7][0] = "66666";
ea[7][1] = "....6";
ea[7][2] = "....6";
ea[7][3] = "....6";
ea[7][4] = "....6";
ea[8][0] = "66666";
ea[8][1] = "6...6";
ea[8][2] = "66666";
ea[8][3] = "6...6";
ea[8][4] = "66666";
ea[9][0] = "66666";
ea[9][1] = "6...6";
ea[9][2] = "66666";
ea[9][3] = "....6";
ea[9][4] = "66666";
}
#include <bits/stdc++.h>
using namespace std;
vector<vector<vector<char>>> numbers;
void output(string digs) {
int len = 0;
int cols = digs.length() * 5 + (digs.length() - 1) * 2;
vector<vector<char>> buf(5, vector<char>(cols, '.'));
for (int i = 0; i < digs.length(); i++)
{
int show = digs[i] - '0';
int istart = i * 7;
for (int j = 0; j < 5; j++)
{
for (int k = 0; k < 5; k++)
{
buf[j][istart + k] = numbers[show][j][k];
}
}
}
for (int i = 0; i < 5; i++)
{
for (int j = 0; j < cols; j++)
{
cout << buf[i][j];
}
cout << endl;
}
}
int main() {
vector<vector<char>> number(5, vector<char>(5, '6'));
auto temp = number;
//0
for (int i = 1; i < 4; i++)
{
temp[i][1] = '.';
temp[i][2] = '.';
temp[i][3] = '.';
}
numbers.push_back(temp);
//1
temp = number;
for (int i = 0; i < 5; i++)
{
for (int j = 0; j < 4; j++)
{
temp[i][j] = '.';
}
}
numbers.push_back(temp);
//2
temp = number;
temp[1][0] = '.';
temp[1][1] = '.';
temp[1][2] = '.';
temp[1][3] = '.';
temp[3][1] = '.';
temp[3][2] = '.';
temp[3][3] = '.';
temp[3][4] = '.';
numbers.push_back(temp);
//3
temp[3][0] = '.';
temp[3][4] = '6';
//4
numbers.push_back(temp);
{
temp = number;
for (int i = 1; i < 4; i++)
{
temp[0][i] = '.';
temp[1][i] = '.';
}
for (int i = 0; i < 4; i++)
{
temp[3][i] = '.';
temp[4][i] = '.';
}
numbers.push_back(temp);
}
//5
temp = numbers[2];
temp[1][0] = '6';
temp[1][4] = '.';
temp[3][0] = '.';
temp[3][4] = '6';
numbers.push_back(temp);
//6
temp[3][0] = '6';
numbers.push_back(temp);
//7
temp = number;
for (int i = 1; i < 5; i++)
{
temp[i][0] = '.';
temp[i][1] = '.';
temp[i][2] = '.';
temp[i][3] = '.';
}
numbers.push_back(temp);
temp = numbers[6];
temp[1][4] = '6';
numbers.push_back(temp);
temp[3][0] = '.';
numbers.push_back(temp);
//output(12);
//output("0123456789");
int n;
cin >> n;
while (n--)
{
stack<char> oper;
stack<int> numb;
string s;
cin >> s;
char ch = '.';
int num = 0;
int i = 0;
while (i<s.length())
{
if (s[i] == '6') {
num = num * 10 + s[i] - '0';
}
else {
break;
}
i++;
}
numb.push(num);
for (; i < s.length();)
{
//操作符
while (!oper.empty())
{
char ch = oper.top();
if (ch == '*')
{
int n1 = numb.top();
numb.pop();
int n2 = numb.top();
numb.pop();
numb.push(n1*n2);
oper.pop();
}
else break;
}
bool falg = false;
if (s[i] == '-')
{
s[i] = '+';
falg = true;
}
oper.push(s[i]);
i++;
//数字
int right = 0;
while (i<s.length())
{
if (s[i] == '6') {
right = right * 10 + s[i] - '0';
}
else {
break;
}
i++;
}
numb.push(falg?-1*right:right);
}
while (!oper.empty())
{
char ch = oper.top();
oper.pop();
int n1 = numb.top();
numb.pop();
int n2 = numb.top();
numb.pop();
if (ch == '+') {
numb.push(n1 + n2);
}
else if(ch == '-'){
numb.push(n1-n2);
}
else {
numb.push(n2*n1);
}
}
num = numb.top();
stringstream ss;
ss << num;
output(ss.str());
}
return 0;
}
百分之10 应该是错在最后的表达式求解。
我自己测试没错,为什么通过是0呢?有什么需要注意的吗?
然后调了一个小时。格式还是有问题
对,一万个**心里爬过去,mmp
感觉太费时间了,果断放弃了这个题。。最后一题还不会QAQ
我这题也调了一个多小时,最后两题都没时间做了 = =
看了半天,才看出来那个是表示数字。。
***机智
好心疼,原来因为前面多了两点一直没过
#n为算式的结果, eval()可以将字符串算式转化为算式结果 def draw(n): lib = ["66666", "6...6", "....6", "6...."] dic = {} target = str(n) length = len(target) res = "" dic[0] = [0,1,1,1,0] dic[1] = [2,2,2,2,2] dic[2] = [0,2,0,3,0] dic[3] = [0,2,0,2,0] dic[4] = [1,1,0,2,2] dic[5] = [0,3,0,2,0] dic[6] = [0,3,0,1,0] dic[7] = [0,2,2,2,2] dic[8] = [0,1,0,1,0] dic[9] = [0,1,0,2,0] for i in range(5): for j in range(length): num = int(target[j]) if j<length-1: res += lib[dic[num][i]]+".." else: res += lib[dic[num][i]] print(res) res = ""
相关推荐
点赞 评论 收藏
分享