C++ 程序以相反顺序连接字符串
假设我们有两段字符串 S 和 T。两者均为小写字母。按此顺序连接 T 和 S 以生成最终字符串。
因此,如果输入为 S = "ramming";T = "prog",则输出将为 "programming"
步骤
为了解决这个问题,我们将按照以下步骤进行操作 −
res := T concatenate S return res
示例
让我们看看以下实施方案以获得更好的理解 −
#include <bits/stdc++.h> using namespace std; string solve(string S, string T){ string res = T + S; return res; } int main(){ string S = "ramming"; string T = "prog"; cout << solve(S, T) << endl; }
Explore our latest online courses and learn new skills at your own pace. Enroll and become a certified expert to boost your career.
输入
"ramming", "prog"
输出
programming
广告