字符串连接(简单模拟)

173 篇文章 3 订阅
90 篇文章 0 订阅


链接: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 1000010

using 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);
	}
}


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

林下的码路

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值