字符串的插入

来源:互联网 发布:淘宝推荐系统 编辑:程序博客网 时间:2024/05/01 13:57
Description 
将字符串t插入到字符串s中,在位置pos后插入。不得使用字符串操作函数,输出组合成的字符串。 
Input 
输入两个字符串(t和s)和要插入的位置(pos) 
Output 
输出组合后的字符串 
Sample Input** 
qwe 
jij 

Sample Output 

jijqwe 

#include <stdio.h>
#include <stdlib.h>
int main()
{
    char c1[20],c2[20];
    int a,i,j;
    gets(c1);
    gets(c2);
    scanf("%d",&a);
    for(i=0; c1[i]!='\0'; i++)
    {


        if(i==a)
        {
            for(j=0; c1[j]!='\0'; j++)
            {
                printf("%c",c1[j]);
            }
        }
        printf("%c",c2[i]);
    }
    return 0;
}

0 0
原创粉丝点击