Run ID 作者 问题 语言 测评结果 Time Memory 代码长度 提交时间
112176 彭士宝 字符串拼接 C++ Accepted 1 MS 276 KB 614 2025-03-08 16:24:05

Tests(10/10):


Code:

#include <iostream> #include <string> using namespace std; int main() { string a, b; int n; // 读取输入 getline(cin, a); // 读取字符串a getline(cin, b); // 读取字符串b cin >> n; // 读取位置n // 拼接字符串 string result = a + b; // 检查位置n是否在范围内 if (n >= 1 && n <= result.length()) { cout << result[n - 1] << endl; // 输出位置n的字符(注意索引从0开始) } else { cout << "Error: Position out of range" << endl; // 位置超出范围的处理 } return 0; }