HDOJ 2087 剪花布条----strstr函数
来源:互联网 发布:真实挂机赚钱软件 编辑:程序博客网 时间:2024/06/05 02:43
http://acm.hdu.edu.cn/showproblem.php?pid=2087
/*
strstr(str1,str2)是一种函数,从字符串str1中查找是否有符串str2,如果有,从str1中的str2位置起,返回str1的指针,如果没有,返回null。
*/
#include<stdio.h>
#include<string.h>
#include<math.h>
#include<ctype.h>
#include<stdlib.h>
#define N 1010
char a[N],b[N];
int main()
{
int t;
int str;
char *p;
while(scanf("%s%s",a,b)&&a[0]!='#')//必须用scanf,而不能用gets()
{
p=a;
t=0;
str=strlen(b);
while((p=strstr(p,b))!=NULL)//strstr(p,b)
{
t++;
p+=str;//从a中b的位置返回a的指针,p+strlen(b)进入第一个b出现之后的位置进行判断
}
printf("%d\n",t);
}
return 0;
}
0 0
- HDOJ 2087 剪花布条----strstr函数
- 【HDU 2087】剪花布条 【KMP or strstr函数】
- hdoj 2087 剪花布条
- HDOJ 2087 剪花布条
- hdoj 2087 剪花布条
- HDOJ 2087 剪花布条
- HDOJ 2087 剪花布条
- hdoj--2087 剪花布条
- hdoj 2087 剪花布条
- HDOJ 2087 剪花布条
- hdoj剪花布条
- HDOJ 2087 剪花布条 [KMP]
- HDOJ 2087 剪花布条【KMP】
- ACM HDOJ 2087 (剪花布条)
- HDOJ 2087 剪花布条 (字符串)
- [HDOJ 2087] 剪花布条 [KMP]
- hdoj 2087 剪花布条 【kmp】
- HDOJ 剪花布条 2087【KMP】
- Xcode中Command Line Tools安装方法
- hdu 1394 求逆序数
- 实用中时间戳与日期互转
- uva 699 The Falling Leaves
- 看书要看好书
- HDOJ 2087 剪花布条----strstr函数
- java之反射
- HDU-1106 排序
- HDOJ 1862 EXCEL排序
- 解决安卓开发文档docs打开过慢的问题
- 用户及文件权限管理
- 泛型基础概念
- MySQL之——服务器保持与MySQL的连接
- 【leetcode】123. Best Time to Buy and Sell Stock III