写一个程序,三个字符串str1,str2,str3组成,如果str2在str1的开头出现,就将str1的开头用str3替代,否则直接输出str1str2str3
- 写回答
- 好问题 0 提建议
- 追加酬金
- 关注问题
- 邀请回答
-
1条回答 默认 最新
- -Undefined_ 2021-11-12 00:24关注
#include <stdio.h> int main () { char s1[100],s2[100],s3[100]; printf("str1:"); scanf("%s",s1); printf("str2:"); scanf("%s",s2); printf("str3:"); scanf("%s",s3); int f=1,i; for(i=0;i<strlen(s2);i++){ if(s1[i]!=s2[i]){ f=0; break; } } printf("output:"); if(f==1){ printf("%s",s3); for(i=strlen(s2);i<strlen(s1);i++){ printf("%c",s1[i]); } }else{ printf("%s%s%s",s1,s2,s3); } return 0; }
本回答被题主选为最佳回答 , 对您是否有帮助呢?解决 无用评论 打赏 举报
悬赏问题
- ¥15 拟通过pc下指令到安卓系统,如果追求响应速度,尽可能无延迟,是不是用安卓模拟器会优于实体的安卓手机?如果是,可以快多少毫秒?
- ¥20 神经网络Sequential name=sequential, built=False
- ¥16 Qphython 用xlrd读取excel报错
- ¥15 单片机学习顺序问题!!
- ¥15 ikuai客户端多拨vpn,重启总是有个别重拨不上
- ¥20 关于#anlogic#sdram#的问题,如何解决?(关键词-performance)
- ¥15 相敏解调 matlab
- ¥15 求lingo代码和思路
- ¥15 公交车和无人机协同运输
- ¥15 stm32代码移植没反应