3409 - 考试二十一:字符替换(2)

通过次数

0

提交次数

0

时间限制 : 1 秒 内存限制 : 128 MB

输入两个字符串str1,str2,将str2中前strlen(str1)个字符替换为str1,剩下的保留,输出结果;

题目输入

输入个字符串,分两行输入

题目输出

输出一行字符串

输入/输出样例

输入格式

nice
beautiful girl

输出格式

nicetiful girl

C语言解答

#include"stdio.h"
#include"stdlib.h"
#include"string.h"
int main()
{
   char str1[20],str2[50];
   int i,j;
   gets(str1);
   gets(str2);
   i=strlen(str1);
     strncpy(str2,str1,i);
   puts(str2);
   return 0;
}