C语言数组字符串C++

相关知识
strcmp strlen strcat 用到字符串的函数,要包含头文件string.h
编程要求
本关的编程任务是补全下面代码片段中Begin至End中间的代码,具体要求如下:编程实现:从键盘上输入两个字符串(每个字符串中不包含空格),若不相等,将短的字符串连接到长的字符串的末尾并输出新字符串(若两个字符串长度相等,则后一个字符串连接到前一个字符串末尾);若相等,则输出第一个字符串。
#include <stdio.h>
int main()
{
    // 请在此添加代码
    /********** Begin *********/

    /********** End **********/
    
    return 0;
}

测试说明
以下是测试样例:输入: good good 输出: good
输入: hel lo 输出: hello
输入: ab ba 输出: abba

如下所示


#include<iostream>
#include"string.h"
using namespace std;


int main(){
  char a[100]={0};
  char b[50]={0};
  scanf("%s %s",&a,&b);
  if(!strcmp(a,b)){
      cout<<a<<endl;
  }else{
      strcat(a,b);
      cout<<a<<endl;
  }
  return 0;
}