SDUT 2125 数据结构实验之串二:字符串匹配
2016-06-19 15:24
417 查看
点击打开题目链接
#include <bits/stdc++.h> #define N 1000010 using namespace std; char _string1 , _string2 ; void cmp(char *str1, char *str2); int main() { while(gets(_string1)) { gets(_string2); cmp(_string1, _string2); } return 0; } void cmp(char *str1, char *str2) { int lenth1 = strlen(str1), lenth2 = strlen(str2); int i = 0, j = 0; while(i < lenth1 && j < lenth2) { if(str1[i+j] == str2[j]) { j++; } else { i ++; j = 0; } } if(str2[j] == '\0') { cout << "YES" << endl; } else { cout << "NO" << endl; } }
相关文章推荐
- JavaScript中数据结构与算法(四):串(BF)
- 数据结构里的串是什么东西?
- 串的抽象数据类型ADT
- 串的顺序存储结构
- 串操作
- 串操作
- BDS之串
- 数据结构之串的KMP模式匹配算法的实现
- 数据结构例程——串的顺序存储应用
- 串 && KMP
- 串,模式匹配Index
- 顺序串的实现
- POJ 2602 Superlong sums(模拟大数加法)
- KMP的next[]的求解方法
- SDUT 2151 Phone Number 2010年山东省第一届ACM大学生程序设计竞赛
- 字符串遇到指定的字符停止输入
- PAT 1007 A除以B (20) (大数取余+除法)
- (字符)串
- 块链(字符)串
- 2015-10-23 【项目1 - 建立顺序串的算法库】