当前位置:网站首页>1163: 亲和串(字符串)
1163: 亲和串(字符串)
2022-04-21 09:06:00 【谦QIAN】
1163: 亲和串(字符串)
题目描述
判断亲和串。亲和串的定义是这样的:给定两个字符串s1和s2,如果能通过s1循环移位,使s2包含在s1中,那么我们就说s2 是s1的亲和串。
输入
本题有多组测试数据,每组数据的第一行包含输入字符串s1,第二行包含输入字符串s2,s1与s2的长度均小于100000。
输出
如果s2是s1的亲和串,则输出"yes",反之,输出"no"。每组测试的输出占一行。
样例输入 Copy
AABCD
CDAA
ASD
ASDF
ab
aba
样例输出 Copy
yes
no
no
来源/分类
#include<stdio.h>
#include<string.h>
#define N 200000
/* 判断亲和串 s1循环移位使s2包含在s1中 只需将s1改为两个连续的s1,再直接判断 strstr(str1,str2) 函数用于判断字符串str2是否是str1的子串。 如果是,则该函数返回str2在str1中首次出现的地址;否则,返回NULL。 */
int main(){
char s1[N],s2[N],s3[N];
while(scanf("%s%s",&s1,&s2)!=EOF){
if(strlen(s1)<strlen(s2)){
printf("no\n");
}
else{
strcpy(s3,s1);//将s1的内容保存在s3
strcat(s1,s3);//将s3的内容接在s1的后面
if(strstr(s1,s2)!=NULL){
printf("yes\n");//判断字符串s2是否是s1的子串
}
else {
printf("no\n");
}
}
}
return 0;
}
版权声明
本文为[谦QIAN]所创,转载请带上原文链接,感谢
https://blog.csdn.net/weixin_44500344/article/details/107941071
边栏推荐
- Open3d读写ply点云文件
- PageRank-案例-机场
- 数据库有张表,其中一个字段存的是json数据,我需要在这张表有更新的时候,解析这个字符串,然后把解析的json数据更新到另外一个表,有什么好的建议?
- sql 一般模糊查询语句,查询表T , 表T2的SEQ是条件,请问模糊查询 如何 能够匹配表T2的SEQ多个字符?
- 【CVPR 2020】PointASNL :Robust Point Clouds Processing using Nonlocal Neural Networks
- 2017我也开始真正写CSDN博客(新浪网易转战CSDN)
- Eight sorts (Part 1)
- Template adaptation guide for toudabi thesis
- 笔记0104. MySQL 高级 - 索引 - 概述
- 头大毕设论文模板适配指南
猜你喜欢

Penetration practice - dig a school site vulnerability (APP vulnerability)

CC00043.CloudJenkins—————————————
![BUUCTF[极客大挑战 2019]Havefun](/img/5a/9b1942c0d24f079be804c7b3304be1.png)
BUUCTF[极客大挑战 2019]Havefun

Meizu, once expected to challenge apple, now lives by providing accessories for Apple users

渗透实战-无回显Rce-thinkphp5-Getshell

2022 Shandong Province safety officer C certificate examination questions and simulation examination

Characteristics of interactive multimedia applications
What is the product power of the new modern paristi, a joint venture 7-seat SUV with large displacement?

Actual combat penetration - fofa dirbrute - code audit - construction POC ueditor - decryption - WAF Godzilla

CC00026.CloudJenkins—————————————
随机推荐
网易博客居然要关了,我写的文章啊!
2022 t elevator repair test questions and online simulation test
中国移动的用户ARPU重新进入上升通道,员工薪酬也稳步上涨
LDO系列--PSRR
ARPU, the user of China Mobile, has re entered the rising channel, and the salary of employees has also increased steadily
极客大挑战 2019 Upload 1
BUUCTF[ACTF2020 新生赛]Include
Compile pyx file into PYD file (many pits have been solved)
Workerman给Timer定时器里的方法传参数
Open3d读写ply点云文件
原生与H5混合式开发详解
Buuctf [actf2020 freshman competition] include
Common computer shortcut keys + common DOS commands
模拟实现vector
批量处理数据对比(<foreach>标签和sqlsession)
Major programming languages and applications in 2022
[ctf.show.reverse] 月饼杯 re1_西北望乡、re2_归心、re3_若无月
Remove linked list elements < difficulty coefficient >
Open3d读写pcd点云文件
[(strongly pushed) Li Hongyi 2021 / 2022 spring machine learning course] unsupervised learning - linear methods