当前位置:网站首页>【计算一个字符串和另一个字符串相等的次数】
【计算一个字符串和另一个字符串相等的次数】
2022-07-26 00:17:00 【李在奋斗……】
#include <iostream>
#include <string.h>
using namespace std;
int main()
{
int m = 0;
string s1;
cout <<"请输入第一个字符串的内容:" << endl;
cin >> s1;
cout << "请输入第二个字符串的内容:" << endl;
string s2;
cin >> s2;
if (s1.length() < s2.length())
{
cout << "没有一个是相等的!" << endl;
}
else
{
for (int i = 0; i < s1.length(); i++)
{
for (int j = 0; j < s2.length(); j++)
{
if (s1[i + j] != s2[j])
{
break;
}
else
{
if (j == s2.length()-1)
{
m++;
i += j;
i--;
}
}
}
}
cout << "有" << m << "个" << endl;
}
return 0;
}

边栏推荐
- HNOI2012矿场搭建
- Tid-mop: a comprehensive framework for security management and control under the scenario of data exchange
- Find and locate commands
- 2022/7/25 考试总结
- After seven years of testing, the interview with Huawei finally negotiated a salary of 10000. HR said that I didn't respect Huawei and they didn't have such a low salary position~
- Study on gene targeting preparation of tissue plasminogen activator loaded on albumin nano ultrasonic microbubbles
- OPENCV学习DAY6
- 一个List到底能存多大的数据呢?
- Understanding of "dbdnet: a deep boosting strategy for imagedenoising"
- 前缀异或和,异或差分数组
猜你喜欢

分布式事务 :可靠消息最终一致性方案

软件测试同行评审到底是什么?

Nest. JS uses express but not completely

NVIDIA programmable reasoning accelerator tensorrt learning notes (III) -- Accelerating reasoning

Redis killed twelve questions. How many questions can you carry?
![[redis] ① introduction and installation of redis](/img/87/af98c862524a81d4636f1cb3be5181.png)
[redis] ① introduction and installation of redis

8个小妙招-数据库性能优化,yyds~

IP Core: PLL

HNOI2012矿场搭建

Pikachu靶机通关和源码分析
随机推荐
CyclicBarrier
什么是 Web3 游戏?
Preparation of bovine serum albumin modified by low molecular weight protamine lmwp/peg-1900 on the surface of albumin nanoparticles
MWEC:一种基于多语义词向量的中文新词发现方法
Wechat applet dynamic style | parameter transfer
What is software testing peer review?
Thymeleaf view integration
The way to understand JS: six common inheritance methods of JS
C语言 预处理详解
Sorting out the encapsulation classes of control elements in appium
Linked list related methods
Hefei approved in advance
[redis] ③ data elimination strategy, pipeline command, publish and subscribe
Duplicate disk: recommended system - negative sampling strategy
redis的使用
Get JD product details original data API
The way of understanding JS: what is prototype chain
2022/7/19 考试总结
快速入门顺序表链表
[contents] mqtt, nodejs projects