西南科技大学Power OJ:实验五 L: 课本第六章-13 字符串连接

Description

将两个字符串连接起来,并将他们输出。
Input
输入两个不包含空格的字符串,字符串长度小于10000。
Output
输出连接起来之后的字符串。

Sample Input
Raw

hello~
w703710691d

**Sample Output**
Raw

hello~w703710691d
Hint
不要用strcat函数

示例代码:

#include <stdio.h>
#include <string.h>
int main ()
{
    
    
	char a[10000];
	char b[10000];
	char c[20001];
	gets(a);
	gets(b);
	int lena=0,lenb=0;
	lena=strlen(a);
	lenb=strlen(b);
	int i;
	for(i=0;i<lena+lenb;i++)
	{
    
    
		if(i<=lena-1)
			c[i]=a[i];
		else
			c[i]=b[i-lena];
		printf("%c",c[i]);
	}
	return 0;
}

Guess you like

Origin blog.csdn.net/qq_45281807/article/details/111463750