NYOJ5 Binary String Matching
Binary String Matching
- 描述
- Given two strings A and B, whose alphabet consist only ‘0’ and ‘1’. Your task is only to tell how many times does A appear as a substring of B? For example, the text string B is ‘1001110110’ while the pattern string A is ‘11’, you should output 3, because the pattern A appeared at the posit
- 输入
- The first line consist only one integer N, indicates N cases follows. In each case, there are two lines, the first line gives the string A, length (A) <= 10, and the second line gives the string B, length (B) <= 1000. And it is guaranteed that B is always longer than A.
- 输出
- For each case, output a single line consist a single integer, tells how many times do B appears as a substring of A.
- 样例输入
-
3
11
1001110110
101
110010010010001
1010
110100010101011 - 样例输出
-
3
0
3#include <iostream>
#include <cstring>
using namespace std; int main()
{
int T;
char a[];
char b[];
int i;
int j;
int count;
int temp;
int a_length;
int b_length; cin >> T;
while (T--)
{
cin >> a >> b; count = ;
a_length = strlen(a);
b_length = strlen(b);
for (i = ;i < b_length-a_length+;i++)
{
temp = i;
for (j = ;j < a_length;temp++,j++)
{
if (b[temp] != a[j])
{
break;
}
} if (j >= a_length)
{
count++;
}
}
cout << count << endl;
}
return ;
}
NYOJ5 Binary String Matching的更多相关文章
- NYOJ5——Binary String Matching
Binary String Matching 时间限制:3000 ms | 内存限制:65535 KB 难度:3 描述:Given two strings A and B, whose alph ...
- Binary String Matching
问题 B: Binary String Matching 时间限制: 3 Sec 内存限制: 128 MB提交: 4 解决: 2[提交][状态][讨论版] 题目描述 Given two strin ...
- NYOJ之Binary String Matching
Binary String Matching 时间限制:3000 ms | 内存限制:65535 KB 难度:3 描述 Given two strings A and B, whose a ...
- ACM Binary String Matching
Binary String Matching 时间限制:3000 ms | 内存限制:65535 KB 难度:3 描述 Given two strings A and B, whose alp ...
- Binary String Matching(kmp+str)
Binary String Matching 时间限制:3000 ms | 内存限制:65535 KB 难度:3 描述 Given two strings A and B, whose alp ...
- NYOJ 5 Binary String Matching
Binary String Matching 时间限制:3000 ms | 内存限制:65535 KB 难度:3 描述 Given two strings A and B, whose alp ...
- 【ACM】Binary String Matching
Binary String Matching 时间限制:3000 ms | 内存限制:65535 KB 难度:3 描述 Given two strings A and B, whose alp ...
- nyoj 题目5 Binary String Matching
Binary String Matching 时间限制:3000 ms | 内存限制:65535 KB 难度:3 描述 Given two strings A and B, whose alp ...
- nyoj 5 Binary String Matching(string)
Binary String Matching 时间限制:3000 ms | 内存限制:65535 KB 难度:3 描述 Given two strings A and B, whose alp ...
随机推荐
- 【Linux】小米路由开启SSH访问权限
一.验证小米路由ROM是否为开发版 1. 登录小米路由Web管理页面,检查ROM版本是否为开发版(若为开发版直接跳至第二步,若为稳定版继续本步骤). 2. 进入小米路由器官网(http://www1 ...
- 洛谷P5055 【模板】可持久化文艺平衡树(FHQ Treap)
题面 传送门 题解 日常敲板子.jpg //minamoto #include<bits/stdc++.h> #define R register #define inline __inl ...
- python自动化测试学习笔记-6excel操作xlwt、xlrd、xlutils模块
python中通过xlwt.xlrd和xlutils操作xls xlwt模块用于在内存中生成一个xls/xlsx对象,增加表格数据,并把内存中的xls对象保存为本地磁盘xls文件; xlrd模块用于把 ...
- NLog简单配置与使用
对项目添加NLog 安装完成后,在项目里面会自动引入该引入的dll,并且会添加如下两个文件 NLog的配置主要是在这个config文件里.当然也可以将这个文件里面的nlog节点复制到项目配置文件App ...
- EditText(7)EditText输入事件监听
EditText.addTextChangedListener(TextWatcher watcher); void initSearch(){ search = (EditText) findVie ...
- 计算型属性 vs 懒加载
只实现 getter 方法的属性被称为计算型属性,等同于 OC 中的 ReadOnly 属性 计算型属性本身不占用内存空间 不可以给计算型属性设置数值 计算型属性可以使用以下代码简写 var titl ...
- MFC_2.10选项卡控件的封装
选项卡控件的封装 1.新建默认MFC项目 2.添加资源Dialog,属性style改child,边框改none,添加类取名CMyDialog1: 同理,CMyDialog2: 3.类向导,添加MFC类 ...
- vue组件---动态组件之多标签页面
首先看下效果图 代码: <!DOCTYPE html> <html> <head> <meta charset="utf-8"> & ...
- 00Cascading Style Sheet
Cascading Style Sheet CSS(Cascading Style Sheet)即层叠样式表,简称样式表.要理解层叠样式表的概念先要理解样式的概念.样式就是对网页中的 元素(字体.段落 ...
- Python自学-1-基本概念问题
C语言适合开发那些追求运行速度.充分发挥硬件性能的程序. Python是用来编写应用程序的高级编程语言. Python提供了 第三方库 & 基础代码库(覆盖了网络.文件.GUI.数据库.文本等 ...