ACM Binary String Match
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
void SubString(char sub[], char s[], int i, int m)
{
int j;
for(j=; j<=m; j++)
sub[j]=s[i++];
sub[j]=NULL;
}
int main()
{
char s[], c[], *sub=NULL;
int num,m,n,i,count;
scanf("%d", &num);
while(num--)
{
scanf("%s", c+);
scanf("%s", s+);
m=strlen(c+);
n=strlen(s+);
sub=(char *)malloc((m+)*sizeof(char));
for(i=,count=; i<=n-m+; i++)
{
SubString(sub,s,i,m);
if(!strcmp(c+,sub+))
count++;
}
printf("%d\n",count);
}
return ;
}
写的自我感觉不错!
ACM Binary String Match的更多相关文章
- ACM 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之Binary String Matching
Binary String Matching 时间限制:3000 ms | 内存限制:65535 KB 难度:3 描述 Given two strings A and B, whose a ...
- 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 ...
- Binary String Matching(kmp+str)
Binary String Matching 时间限制:3000 ms | 内存限制:65535 KB 难度:3 描述 Given two strings A and B, whose alp ...
- encode_json 会对给定的Perl的数据结构转换为一个UTF-8 encoded, binary string.
use JSON qw/encode_json decode_json/ ; use Encode; my $data = [ { 'name' => 'Ken' , 'age' => 1 ...
- perl encode_json 会产生 UTF-8 (binary) string decode_json 需要一个 UTF-8 (binary) string
encode_json $json_text = encode_json $perl_scalar Converts the given Perl data structure to a UTF-8 ...
- NYOJ 5 Binary String Matching
Binary String Matching 时间限制:3000 ms | 内存限制:65535 KB 难度:3 描述 Given two strings A and B, whose alp ...
随机推荐
- css3设置边框属性
css设置边框属性:设置边框圆角 <!DOCTYPE html> <html> <head lang="en"> <meta charse ...
- C++11 std::chrono库详解
所谓的详解只不过是参考www.cplusplus.com的说明整理了一下,因为没发现别人有详细讲解. chrono是一个time library, 源于boost,现在已经是C++标准.话说今年似乎又 ...
- Spring In Action(第三版)读书笔记
第一章 Spring之旅 POJO: plain old java object 简单的java对象 DI:Dependency Injection 依赖注入 构造器注入:构造时作为构造器参数传入 p ...
- 自动备份mysql
创建备份文件存放的目录 mkdir /usr/local/dbbak 脚本:vi /usr/local/mysqlback.sh # /bin/bash DB_NAME="dsideal_d ...
- JavaScript实现存储HTML字符串
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> <html> <head ...
- 洛谷 P1092 虫食算 Label:dfs
题目描述 所谓虫食算,就是原先的算式中有一部分被虫子啃掉了,需要我们根据剩下的数字来判定被啃掉的字母.来看一个简单的例子: 43#9865#045 +8468#6633 44445509678 其中# ...
- css3+js打造炫酷图片展示
<!DOCTYPE html> <html onselectstart="return false"> <!-- onselectstart=&quo ...
- iOS 让启动页面延迟的方法
<1> 利用多线程的方法:[NSThread sleepForTimeInterval:300];
- UpdatePanel完成后调用js
引言: asp.net 微软引入了UpdatePanel 使用起来很方便 如果 我们想UpdatePanel加载完成后做一些事情 需要使用js <script type="text/j ...
- Mockito学习资料
官网:http://mockito.org/ https://dzone.com/refcardz/mockito