字符串连接(简单模拟)

来源:互联网 发布:软件开发流程管理规范 编辑:程序博客网 时间:2024/05/17 00:58


链接:https://www.nowcoder.com/practice/40d83e5509b04d20825ae68fe35e9ca8?tpId=40&tqId=21540&tPage=11&rp=11&ru=/ta/kaoyan&qru=/ta/kaoyan/question-ranking
来源:牛客网

题目描述

不借用任何字符串库函数实现无冗余地接受两个字符串,然后把它们无冗余的连接起来。 
输入描述:
每一行包括两个字符串,长度不超过100。


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

输入例子:
abc def

输出例子:
abcdef

AC code:

#include<iostream>#include<algorithm>#include<stdio.h>#include<map>#include<math.h>#include<string.h>#include<queue>#include<vector>#include<set>#define LL long long#define exp 1e-9#define MAXN 1000010using namespace std;void Mystrcat(char s1[],char s2[]){int i,j,len1,len2;char s3[222]="";i=j=0;while(s1[i]!='\0'){s3[j]=s1[i];i++;j++;}i=0;while(s2[i]!='\0'){s3[j]=s2[i];i++;j++;}s3[j]='\0';puts(s3);}int main(){//freopen("D:\\in.txt","r",stdin);char s1[111],s2[111];while(scanf("%s%s",&s1,&s2)!=EOF){Mystrcat(s1,s2);}}


0 0
原创粉丝点击