汕大小吴:80%的offer掌握在20%的人手中,而你就是那20%。
投递字节跳动等公司10个岗位 >
0 点赞 评论 收藏
分享
Reyzal:#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 点赞 评论 收藏
分享
投递多益网络等公司10个岗位 >
0 点赞 评论 收藏
分享
关注他的用户也关注了: