题目1206:字符串连接
时间限制:1 秒
内存限制:128 兆
特殊判题:否
提交:4010
解决:1915
-
题目描述:
-
不借用任何字符串库函数实现无冗余地接受两个字符串,然后把它们无冗余的连接起来。
-
输入:
-
每一行包括两个字符串,长度不超过100。
-
输出:
-
可能有多组测试数据,对于每组数据,
不借用任何字符串库函数实现无冗余地接受两个字符串,然后把它们无冗余的连接起来。
输出连接后的字符串。
-
样例输入:
-
abc def
-
样例输出:
-
abcdef
-
来源:
- 2010年华中科技大学计算机保研机试真题
-
#include<iostream> #include<string.h> #include<stdio.h> using namespace std; int main() { char a[202],str[101],st[101]; while(cin>>st>>str) { int len; len=strlen(st); int len2=strlen(str); for(int i=0;i<len;i++) { a[i]=st[i]; } for(int j=0;j<len2;j++) { a[j+len]=str[j]; } a[len+len2]='\0'; int len3=strlen(a); for(int i=0;i<len3;i++) { cout<<a[i]; } cout<<endl; } }