题解 | #字符串连接#

字符串连接

https://www.nowcoder.com/practice/40d83e5509b04d20825ae68fe35e9ca8

#include <stdio.h>

int main() {
    char a[100];char b[100];char c[200];
    while(scanf("%s %s",&a,&b)!=EOF){
        int i=0;int j=0;
        while(1){
            if(a[i]!='\0'){i++;
            }else{break;}
        }
        
        while(1){
            if(b[j]!='\0'){j++;
            }else{break;}
        }
        for(int temp=0;temp<i;temp++){
            c[temp]=a[temp];
        }
        for(int temp=i;temp<i+j;temp++){
            c[temp]=b[temp-i];
        }
        c[i+j]='\0';
        printf("%s\n",c);
    }
    return 0;
}

全部评论

相关推荐

评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务