一:
试题编号: | 2019-3-1 |
试题名称: | 小中大 |
时间限制: | 1.0s |
内存限制: | 256.0MB |
问题描述: |
#include <iostream>
using namespace std;
int main() {
//n个整数
int n;
//最大值,中位数,最小值
int max, mid1, min; float mid2;
//数组
int num[100];
//输入过程
cin >> n;
for (int i = 0; i < n; i++) {
cin >> num[i];
}
max = num[0]; min = num[n - 1];
int temp = max;
if (max < min) {
max = min;
min = temp;
}
if (n % 2 == 0) {
mid1 = (max + min) / 2;
mid2 = float(max + min) / 2;
if (mid2 != int(mid2)) {
if (int(mid2 * 100) % 10 >= 5) {
mid2 += 0.1;
}
printf("%d %.1f %d", max, mid2, min);
}
else
printf("%d %d %d", max, mid1, min);
}
else {
mid1 = num[n / 2];
printf("%d %d %d", max, mid1, min);
}
return 0;
}
二:
试题编号: | 2019-3-2 |
试题名称: | 二十四点 |
时间限制: | 1.0s |
内存限制: | 256.0MB |
问题描述: |
#include <iostream>
using namespace std;
int main() {
//n次运算
int n;
//运算数和运算符的字符串
string s;
//符号栈
char c[3];
int topC = 0;
//运算数栈
int num[4];
int topN = 0;
//结果
int res[100] = { 0 };
//输入过程
cin >> n;
for (int i = 0; i < n; i++) {
cin >> s;
int count = 1;
for (int j = 0; j < 7; j++) {
if (j % 2 == 0) {
num[topN] = s[j] - '0';
//cout << num[topN]<<endl;
topN++;
}
else {
if (s[j] == 'x') {
num[topN - 1] = num[topN - 1] * (s[j + 1] - '0');
j++;
}
else if (s[j] == '/') {
num[topN - 1] = num[topN - 1] / (s[j + 1] - '0');
j++;
}
else if (s[j] == '+') {
if (topC > 0 && c[topC - 1] == '+' ) {
num[topN - 2] = num[topN - 2] + num[topN - 1];
topN--;
c[topC - 1] = '+';
}
else if (topC > 0 && c[topC - 1] == '-') {
num[topN - 2] = num[topN - 2] - num[topN - 1];
topN--;
c[topC - 1] = '-';
}
else if (topC == 0) {
c[topC] = '+';
topC++;
}
}
else if (s[j] == '-') {
if (topC > 0 && c[topC - 1] == '+') {
num[topN - 2] = num[topN - 2] + num[topN - 1];
topN--;
c[topC - 1] = '+';
}
else if (topC > 0 && c[topC - 1] == '-') {
num[topN - 2] = num[topN - 2] - num[topN - 1];
topN--;
c[topC - 1] = '-';
}
else if (topC == 0) {
c[topC] = '-';
topC++;
}
}
}
}
if (topC > 0 && c[topC - 1] == '+') {
num[0] = num[0] + num[1];
}
else if (topC > 0 && c[topC - 1] == '-') {
num[0] = num[0] - num[1];
}
res[i] = num[0];
num[0] = 0;
topC = topN = 0;
}
//输出过程
for (int i = 0; i < n; i++) {
if (res[i] == 24)
cout << "Yes" << endl;
else
cout << "No" << endl;
}
return 0;
}
三:
试题编号: | 2019-3-3 |
试题名称: | 损坏的RAID5 |
时间限制: | 1.0s |
内存限制: | 256.0MB |
问题描述: | 未解答 |
四:
试题编号: | 2019-3-4 |
试题名称: | 消息传递接口 |
时间限制: | 1.0s |
内存限制: | 256.0MB |
问题描述: | 未解答 |
五:
试题编号: | 2019-3-5 |
试题名称: | 317号子任务 |
时间限制: | 1.0s |
内存限制: | 256.0MB |
问题描述: | 未解答 |