swustoj(字符串查找(0448))
来源:互联网 发布:超市购物篮数据下载 编辑:程序博客网 时间:2024/06/07 12:03
在一段句子中找出给定字符串出现在句子中第一个字母出现的位置。 句子中字符个数小于4500。 字符串字符个数小于120。
Description
两行 第一行是给定字符串 第二行是句子
Input
整数,字符串出现的位置
Output
abcde
this is a Example of abcde!
Sample Input
22
#include<stdio.h>#include<iostream>using namespace std;int main(){char ch[121];char a[4501];int lc;for (int i = 0;; i++){scanf("%c", &ch[i]);//不知道为什么cin不可以,求路过的大神解释一波if (ch[i] == '\n'){lc = i;//记录长度break;}}int k;for (int i = 0;; i++){scanf("%c", &a[i]);if (a[i] == '\n'){k = i;break;}}for (int i = 0; i < k - lc + 1; i++){int l = 0;int vs = 0;for (int j = i; j < lc + i - 1; j++, l++){if (ch[l] != a[j]){vs = 1;break;}}if (!vs){cout << i + 1 << endl;break;}}return 0;}
1 0
- swustoj字符串查找(0448)
- swustoj(字符串查找(0448))
- swustoj前缀字符串(0185)
- (swustoj)二叉排序树的实现和查找(1011)
- swustoj---1091
- swustoj(667)
- 查找字符串
- 查找字符串
- 查找字符串
- 查找字符串
- 查找字符串
- 查找字符串
- 字符串查找
- 字符串查找
- 查找字符串
- 查找字符串
- 字符串查找
- 查找字符串
- 整数的拆分
- 005-023-Merge k sorted lists 归并K个有序的链表
- 2017.4.15模拟赛总结
- 如何安装Composer
- 多线程操作例题
- swustoj(字符串查找(0448))
- PRML读书笔记——采样方法
- tcpdump+wireshark的使用
- Oracle数据库被锁住问题
- 数据库几个操作的专业叫法
- GPLT-古风排版
- Machine Learning第三讲[Logistic回归] --(二)Logistic回归模型
- iOS中respondsToSelector方法的作用
- CSS hack IE常见兼容性问题