大家可以趁着这道题复习一波C语言中关于str的相关函数。确实省了不少事
参考代码:
#include <stdio.h> #include <string.h> #include <stdlib.h> #include <math.h> int main() { char s1[100000] = {'\0'}, s2[100000] = {'\0'}; while (scanf("%s%s", s1, s2) != EOF) { char str[100000] = {'\0'};//开辟一个新字符串数组 //把s1复制2份放进str中,例如s1="ABC",则操作结束后str="ABCABC" strcat(str, s1);//srtcat(s1,s2)的作用是在s1后面追加s2 strcat(str, s1); //strstr(s1, s2)返回s2在s1中出现的位置,找到则返回位置,找不到则返回NULL if (strstr(str, s2) != NULL) { printf("yes\n"); } else { printf("no\n"); } } return 0; }
0.0分
2 人评分
C语言程序设计教程(第三版)课后习题6.1 (C语言代码)浏览:595 |
【绝对值排序】 (C++代码)浏览:670 |
【亲和数】 (C语言代码)浏览:501 |
C语言程序设计教程(第三版)课后习题8.5 (C语言代码)浏览:536 |
用筛法求之N内的素数。 (C语言代码)浏览:803 |
C语言程序设计教程(第三版)课后习题9.6 (C语言代码)浏览:373 |
1642题解浏览:712 |
C语言程序设计教程(第三版)课后习题4.9 (C语言代码)浏览:560 |
1048题解(读入回车问题)浏览:555 |
C二级辅导-同因查找 (C语言代码)浏览:563 |