首页 > 试题广场 >

字符串连接

[编程题]字符串连接
  • 热度指数:16468 时间限制:C/C++ 1秒,其他语言2秒 空间限制:C/C++ 64M,其他语言128M
  • 算法知识视频讲解
不借用任何字符串库函数实现无冗余地接受两个字符串,然后把它们无冗余的连接起来。

输入描述:
每一行包括两个字符串,长度不超过100。


输出描述:
可能有多组测试数据,对于每组数据,
不借用任何字符串库函数实现无冗余地接受两个字符串,然后把它们无冗余的连接起来。
输出连接后的字符串。
示例1

输入

abc def

输出

abcdef
头像 路人萌Miranda
发表于 2022-03-16 00:09:28
#include <cstdio> using namespace std; int main() { char str1[300], str2[100]; while (scanf("%s%s", str1, str2) != EOF) { int i = 0; wh 展开全文
头像 在考古的小鱼干很有气魄
发表于 2023-03-06 09:38:11
感觉题目的无冗余的意思是要求去重,结果给的测试案例是拼接的意思.....(我理解错了?)将下面代码的注释去掉即可实现去重 #include <bits/stdc++.h> using namespace std; int main(){ string s1,s2,res; cin& 展开全文
头像 牛客440904392号
发表于 2024-10-03 16:24:11
//C语言版代码 #include <stdio.h> int main() { char s[100], t[100]; scanf("%s%s", s, t); printf("%s%s\n", s, t); r 展开全文
头像 easeoff
发表于 2025-02-21 22:51:41
#include <stdio.h> #include <string.h> int main() { int i; char str1[300], str2[100], str[402]; scanf("%s %s", str1, 展开全文
头像 WonderFF
发表于 2024-03-16 19:40:45
//感觉这个题应该不是一个上机的题 //法一,直接输出,这种方法算钻了空子吧 #include<iostream> using namespace std; int main() { string str1, str2; while (cin >> str1 >&g 展开全文
头像 🐮🐮牛_
发表于 2022-01-13 15:22:43
如代码所示 ```#include<iostream> #include<cstring> using namespace std; int main(){ char s1[300],s2[100]; while(scanf("%s %s",&s1, 展开全文
头像 用户抉择
发表于 2021-03-30 10:26:18
#include <stdio.h> #include <string.h> void MyStrCat(char dstStr[],char scrStr[]){     int&nb 展开全文
头像 lovekang
发表于 2024-08-02 08:45:15
题目比较容易,这里大家主要需要记住的是c语言中,字符串的结尾是'\0'其他的就是遍历即可。 #include <stdio.h> int main() { char a[205], b[105]; while (scanf("%s %s", a, b 展开全文
头像 牛客174565800号
发表于 2025-07-04 01:03:53
#include<iostream> using namespace std; #include <algorithm> int main() { string s; getline(cin, s); int n = s.size(); / 展开全文
头像 牛客174565800号
发表于 2025-07-04 01:04:35
#include<iostream> using namespace std; #include <algorithm> int main() { string s; getline(cin, s); int n = s.size(); / 展开全文