摘要: 在搜狗笔试中遇到一个题,说让用正则表达式匹配货币,货币的格式如下:1,234,234.56小数点保留两位。当时写的不太正确,现在好好思考了一下,需要注意的地方有两点:排除非货币的情况,也就是说货币的首位不为0,也就是不能匹配02,234.56如果是0.56的情况也要匹配到.现将自己的 正则表达式写出来,如果网友有什么好的正则表达式,一定要告诉我。1 ^([1-9][0-9]{0,2}(,[0-9]{3})*|0)\.[0-9]{2}思路如下,分成两种情况,一种是2,456,345.56,另一种是0.56的情况。第一种情况:首位不为0,所以首先是[1-9],但是第一部分最高可能有3位,最低1位, 阅读全文
posted @ 2012-10-03 09:54 bjtulq 阅读(1307) 评论(0) 推荐(0)
摘要: #include "stdio.h" #include "string.h" #include "stdlib.h" struct dictree { struct dictree *child[26]; int n; }; //结点结构,有26个子节点struct dictree *root; void insert (char *source) { int len,i,j; struct dictree *current,*newnode; len=strlen(source); if(len==0) return; curren 阅读全文
posted @ 2011-07-19 08:52 bjtulq 阅读(276) 评论(0) 推荐(0)
摘要: 最近在看字符串匹配算法,参考了文章:http://www.cppblog.com/mythit/archive/2009/04/21/80633.html以下我给出了AC算法的C语言实现,题目是http://acm.hdu.edu.cn/showproblem.php?pid=2222/* * ac.c--多模式匹配算法 * * Created on: Jul 14, 2011 * Author: root */#include <stdio.h>#include <malloc.h>#include <stdlib.h>#include <strin 阅读全文
posted @ 2011-07-15 15:43 bjtulq 阅读(1991) 评论(0) 推荐(0)