csp201903-2
时间: 2023-10-31 08:18:03 浏览: 112
引用: 这是2020年CSP-J入门单项选择题解析,解析明白,一看就懂。整理不易,文章出错评论区说,看见必改。请一键三连,给个五星好评。小编那么拼,给个赞再撤┗|`O′|┛ 嗷~~。
引用: 子任务中显示测试点2正确个数为0,因此,可以用如下方法,骗到10分。以下是一个C++的代码示例:
#include <iostream>
using namespace std;
int main() {
int n;
cin >> n;
for (int i = 0; i < n; i++) {
cout << "No" << endl;
}
return 0;
}
以上代码会输出n个"No",可以通过测试点2并获得10分。
引用: 这是一个使用数组和栈实现的C++代码示例:
#include <iostream>
#include <stack>
using namespace std;
int main() {
char a[100];
int n;
cin >> n;
for (int i = 0; i < n; i++) {
cin >> a[i];
}
for (int i = 0; i < n; i++) {
int num; //运算数
char oper; //运算符
int sum = 0;
for (int j = 0; j < 7; j++) {
if (j % 2 == 0)
num[j / 2] = a[i][j] - 48; //0的ASSIC码为48
else
oper[j / 2] = a[i][j];
}
stack<int> snum;
stack<char> soper;
snum.push(num);
for (int i = 0; i < 3; i++) {
if (oper[i] == 'x' ||oper[i] == '/') {
int temp = snum.top();
snum.pop();
if (oper[i] == 'x')
snum.push(temp * num[i + 1]);
else
snum.push(temp / num[i + 1]);
} else if (oper[i] == '-') {
snum.push(-num[i + 1]);
soper.push(oper[i]);
} else {
snum.push(num[i + 1]);
soper.push(oper[i]);
}
}
sum = snum.top();
snum.pop();
for (int i = 0; i < soper.size(); i++) {
sum += snum.top();
snum.pop();
}
if (sum == 24)
cout << "Yes" << endl;
else
cout << "No" << endl;
}
}
以上代码实现了一个解析给定算术表达式是否等于24的程序。
问题:请告诉我,csp201903-2是什么?
csp201903-2是一个CSP(全国计算机科学与技术专业资格考试)的题目编号,表示该题是2019年3月份的第2道题目。具体题目内容需要查阅相关资料来获取。<span class="em">1</span><span class="em">2</span><span class="em">3</span>
#### 引用[.reference_title]
- *1* [2020年CSP-J入门单项选择题解析](https://download.csdn.net/download/sjy100401/88234366)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_2"}}] [.reference_item style="max-width: 33.333333333333336%"]
- *2* [CSP 201903-2 二十四点 (C++)](https://blog.csdn.net/qq_39876147/article/details/117091994)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_2"}}] [.reference_item style="max-width: 33.333333333333336%"]
- *3* [CSP201903-2二十四点](https://blog.csdn.net/weixin_43074474/article/details/101128023)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_2"}}] [.reference_item style="max-width: 33.333333333333336%"]
[ .reference_list ]
阅读全文