C语言C++字符数组

任务描述
题目描述:输入两个字符串a和b,将b串中的最大字符插入到a串中最小字符后面。
相关知识(略)
编程要求
请仔细阅读下面代码,结合相关知识,在Begin-End区域内进行代码补充。 输入 输入一段文字 输出 输入两个字符串a和b。
测试说明
样例输入: MynameisAmy MynameisJane 样例输出: MynameisAymy 提示:字符串长度不超过100
注意:使用gets()**函数会引起警告并不是报错,只要代码编译正确并不会影响测评结果。 **推荐使用:fgets()函数。
#include <stdio.h>
#include <string.h>
int main(void)
{
    /Begin/

    /End*/
    return 0;
}


#include<stdio.h>
#include<string.h>
char a[105], b[105];
int main(void)
{
    fgets(a, 105, stdin);
    getchar();
    fgets(b, 105, stdin);
    char amin = a[0], bmax = b[0];
    int aminp = 0, lena = strlen(a), lenb = strlen(b);
    for (int i = 1; i < lena-1; i++) {
        if (a[i] < amin) {
            amin = a[i];
            aminp = i;
        }
    }
    for (int i = 1; i < lenb-1; i++) {
        if (b[i] > bmax) {
            bmax = a[i];
        }
    }
    for (int i = 0; i <= aminp; i++) {
        printf("%c", a[i]);
    }
    printf("%c", bmax);
    for (int i = aminp + 1; i < lena-1; i++) {
        printf("%c", a[i]);
    }
    return 0;
}


 觉得有用的话采纳一下哈

我没有完全按照你的要求编写,但总体功能和要求一致。你可以参考。
#include <stdio.h>
#include <string.h>

int main()
{
char s1[20]="MynameisAmy",c1='z';
char s2[20]="MynameisJane",c2='0';
int i,k1;
for(i=0; i<strlen(s1)-1; i++)
if(c1>=s1[i])
{
k1=i;
c1=s1[i];
}
for(i=0; i<strlen(s2)-1; i++)
if(c2<=s2[i])
c2=s2[i];
s1[strlen(s1)]='\0';
for(i=strlen(s1); i>k1+1; i--)
s1[i]=s1[i-1];
s1[k1+1]=c2;
puts(s1);
return 0;
}