C/C++实现

3个回答

google nfa dfa 有穷自动机 词法分析C++ 等关键字

yu_sn0w 我当然知道正则表达式，问题是要用c/c++写。相当于正则表达式在这方面的底层实现
4 年多之前 回复

Problem Description In Computer Science, pattern matching is the act of checking if a certain sequence conforms (matches) a given pattern. Patterns are usually specified using a language based on regular expression. In this problem, we'll use a simple regular expression to express patterns on sequences of decimal digits. A pattern is a sequence of one or more decimal digits `0' ...`9', asterisks `*', and hash signs `#'. A `*' denotes a sequence of an even number of digits, whereas a `#' denotes a sequence of an odd number of digits. For example, the pattern ``129" only matches the sequence 129. The pattern ``1*3" matches all sequences beginning with 1, ending with 3, and having an even number of decimal digits between the first and last digits. As another example, the pattern ``#55" matches the sequences 155, 12355, 1234555, but none of the sequences 55, 1255, 123455. Your task is to write a program to find if a given sequence matches a given pattern. Input Your program will be tested on one or more data sets. Each data set contains a single pattern and one or more sequences to match. The first line of each data set specifies the pattern, and the remaining lines specify the sequences to match against that pattern. The end of a data set (except the last) is identified by the word ``END" (without the double quotes.) The end of the last data set is identified by the word ``QUIT". All lines are 100,000 characters long or shorter. Output k .s . result Where k is the test case number (starting at one,) and s is the sequence number (starting at one within each test case,) and result is either the word ``match" if the given string matches the pattern, or the word ``not" if it doesn't. Sample Input 129 1299 129 1129 END 1*3 123 1223 END #55 155 12355 55 1255 QUIT Sample Output 1.1. not 1.2. match 1.3. not 2.1. not 2.2. match 3.1. match 3.2. match 3.3. not 3.4. not
python 路径匹配中的 *和**通配符用法

Problem Description WisKey downloaded much software in winter vacation, and the disk was in a state of confusion. He wastes many times to find the file everyday. So he wants a tool to help him do this work. The file name consists of lowercase letters. The name pattern is a string of lowercases, '?'s and '*'s. In a pattern, a '?' matches any single lowercase, and a '*' matches none or more lowercases. Let’s do this~ Input The first line of input contains two integers N (0 < N <= 10000) and M (0 < M <=100), representing the number of file names and the number of word patterns. Each of the following N lines contains a file name. After those, each of the last M lines contains a name pattern. You can assume that the length of patterns will not exceed 6, and the length of file names will not exceed 20. There are multiple cases in the data file, process to end of file. Output For each pattern, print a line contains the number of matched file names. If there is no file name that can match the pattern, print "Not match". Sample Input 4 5 this the an is t* ?h*s ??e* *s e Sample Output 2 1 1 2 Not match

``` xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:p="http://www.springframework.org/schema/p" xmlns:aop="http://www.springframework.org/schema/aop" xmlns:tx="http://www.springframework.org/schema/tx" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.1.xsd http://www.springframework.org/schema/tx/spring-tx-3.1.xsd http://www.springframework.org/schema/aop/spring-aop-3.1.xsd"> <!--配置sessionFactory 将数据源注入，并设置hibernate的基本配置 --> <bean id="datasource" class="org.apache.commons.dbcp.BasicDataSource"> <property name="driverClassName" value="com.mysql.jdbc.Driver"></property> <property name="url" value="jdbc:mysql://localhost:3306/hiber_first"></property> <property name="username" value="root"></property> <property name="password" value="chen007"></property> </bean> <bean id="sessionFactory" class="org.springframework.orm.hibernate4.LocalSessionFactoryBean"> <property name="dataSource" ref="datasource"></property> <property name="hibernateProperties"> <props> <prop key="hibernate.dialect"> org.hibernate.dialect.MySQLDialect </prop> <prop key="hibernate.show_sql">true</prop> <prop key="hibernate.hbm2ddl.auto">update</prop> </props> </property> <!-- 配置映射文件， --> <property name="mappingResources" value="cn/cc/vo/Person.hbm.xml"/> </bean> <!--将SessionFactory 注入DAO,拥有sessionFactory容器后才容易进行presistent操作 --> <bean id="userDao" class="cn.cc.springIntergratingHibernate.IUserDaoImpl"> <property name="sessionFactory" ref="sessionFactory"></property> </bean> <!--设置事务管理，需要注入sessionFactory --> <bean id="transactionManager" class="org.springframework.orm.hibernate4.HibernateTransactionManager"> <property name="sessionFactory" ref="sessionFactory" /> <!--配置事务增强处理器 --> </bean> <tx:advice id="txAdvice" transaction-manager="transactionManager"> <tx:attributes> 所有以get开头的方法只有只读权限 <tx:method name="get*" read-only="true"/> 其他方法使用默认设置 <tx:method name="*"/> </tx:attributes> </tx:advice> <aop:config> <!--指定在IUserDao切入点 使用txAdvice事务增强处理--> <aop:pointcut expression="bean(IUserDao)" id="userPointcut"/> <aop:advisor advice-ref="txAdvice" pointcut-ref="userPointcut"/> </aop:config> <!--配置事务拦截器 transactionInterceptor,需要注入TransactionManager --> <bean id="transactionInterceptor" class="org.springframework.transaction.interceptor.TransactionInterceptor"> <!--为事务拦截器注入一个管理器 --> <property name="transactionManager" ref="transactionManager"></property> <property name="transactionAttributes"> <!--定义事务传播属性 --> <props> <prop key="save">PROPAGATION_REQUIRED</prop> <prop key="delete">PROPAGATION_REQUIRED</prop> <prop key="check">PROPAGATION_REQUIRED</prop> </props> </property> </bean> <!--定义BeanNameAutoProxyCreator代理，自动创建相关bean --> <bean class="org.springframework.aop.framework.autoproxy.BeanNameAutoProxyCreator"> <!--指定哪些bean自动生成代理 --> <property name="beanNames"> <list> <value>userDao</value> </list> </property> <property name="interceptorNames"> <list> <value>transactionInterceptor</value> </list> </property> </bean> </beans> ``` 可以看出来nameSpace已经导入了相关的应用了，但还是找不到

# java编程思想的泛型 15.10 通配符章节有这样一段代码 ``` package holder; public class Holder<T> { private T value; public Holder() { } public Holder(T val) { value = val; } public T get() { return value; } public void set(T val) { value = val; } } ``` ``` package holder; public class Wildcards { static <T> T wildSubType(Holder<? extends T> holder, T arg) { T t = holder.get(); return t; } static <T> void wildSuperType(Holder<? super T> holder, T arg) { holder.set(arg); Object obj = holder.get(); } public static void main(String[] args) { Holder<?> unbounded = new Holder<Long>(); Long lng = 1L; Object r11 = wildSubType(unbounded, lng); //The method wildSuperType(Holder<? super T>, T) //in the type Wildcards is not applicable //for the arguments (Holder<capture#5-of ?>, Long) //wildSuperType(unbounded,lng); } } ``` 为什么wildSubType(Holder<? extends T> holder, T arg) 方法可以接受 Holder<?> 作为参数 而 wildSuperType(Holder<? super T> holder, T arg) 却不能接受H older<?> 按照我自己的理解 应该两个都报错 ------- 讲一个题外话 ---- 我用工作电脑 两个都报错 用自己的电脑 就和书中写的一样 jdk都是1.8 很迷

Maven 如何替换test/resources目录中配置文件的通配符
Maven 如何替换test/resources目录中配置文件的通配符？

AFNetworking valueForKeyPath通配符

sql 通配符小问题 在线急等

Java学习的正确打开方式

Python——画一棵漂亮的樱花树（不同种樱花+玫瑰+圣诞树喔）

HashMap 相关概念 HashTab、HashMap、TreeMap 均以键值对像是存储或操作数据元素。HashTab继承自Dictionary，HashMap、TreeMap继承自AbstractMap，三者均实现Map接口 **HashTab：**同步哈希表，不支持null键或值，因为同步导致性能影响，很少被使用 **HashMap：**应用较多的非同步哈希表，支持null键或值，是键值对...

linux系列之常用运维命令整理笔录

Python 基础（一）：入门必备知识

Python十大装B语法
Python 是一种代表简单思想的语言，其语法相对简单，很容易上手。不过，如果就此小视 Python 语法的精妙和深邃，那就大错特错了。本文精心筛选了最能展现 Python 语法之精妙的十个知识点，并附上详细的实例代码。如能在实战中融会贯通、灵活使用，必将使代码更为精炼、高效，同时也会极大提升代码B格，使之看上去更老练，读起来更优雅。 1. for - else 什么？不是 if 和 else 才

2019年11月中国大陆编程语言排行榜
2019年11月2日，我统计了某招聘网站，获得有效程序员招聘数据9万条。针对招聘信息，提取编程语言关键字，并统计如下： 编程语言比例 rank pl_ percentage 1 java 33.62% 2 c/c++ 16.42% 3 c_sharp 12.82% 4 javascript 12.31% 5 python 7.93% 6 go 7.25% 7

JDK12 Collectors.teeing 你真的需要了解一下

“狗屁不通文章生成器”登顶GitHub热榜，分分钟写出万字形式主义大作

《程序人生》系列-这个程序员只用了20行代码就拿了冠军

11月8日，由中国信息通信研究院、中国通信标准化协会、中国互联网协会、可信区块链推进计划联合主办，科技行者协办的2019可信区块链峰会将在北京悠唐皇冠假日酒店开幕。 　　区块链技术被认为是继蒸汽机、电力、互联网之后，下一代颠覆性的核心技术。如果说蒸汽机释放了人类的生产力，电力解决了人类基本的生活需求，互联网彻底改变了信息传递的方式，区块链作为构造信任的技术有重要的价值。 　　1...