摘要: 我们最经常遇到的验证,就是电子邮件地址验证。网站上常见。各种网页脚本也都常用“正则表达式”(regular expression)对我们输入的电子邮件地址进行验证,判断是否合法。有的还能分解出用户名和域名。现在用C++语言实现一下电子邮件地址验证程序,用的是C++ 11标准新增加的STL正则表达式。 源代码如下,该代码已在Visual Studio 2010上验证通过。g++ 4.6不支持C++ 11的STL正则表达式,g++ 4.6上编译可以通过,但运行时错误,抛出regex_error异常。因此,如果要在g++ 4.6上使用正则表达式,请用GNU正则表达式库或者用boost正则表达式... 阅读全文
posted @ 2012-10-07 12:50 叶剑飞Victor 阅读(9157) 评论(1) 推荐(0) 编辑
摘要: 以前操作系统课程设计的时候,我们在Linux操作系统中用C语言和POSIX线程库编写过线程同步与互斥。/* * thread_synchronization.c * * Copyright 2012 叶剑飞 * * 编译命令: * gcc thread_synchronization.c -o thread_synchronization \ * -std=gnu99 -pedantic-errors -D_REENTRANT -pthread -Wall * */#include #include #include #include #incl... 阅读全文
posted @ 2012-10-07 01:02 叶剑飞Victor 阅读(6924) 评论(0) 推荐(1) 编辑
摘要: BNU OJ第26303题Touchscreen Keyboard(题目链接)的解题报告。 原题如下:Touchscreen KeyboardProblem DescriptionNowadays, people do not use hardware keyboards but touchscreens. Usually, they touch on the wrong letters with their chunky fingers, because screen space is precious and the letters therefore too small.Usual... 阅读全文
posted @ 2012-10-04 03:00 叶剑飞Victor 阅读(684) 评论(0) 推荐(0) 编辑
摘要: ACM-ICPC Live Archive 第4889题,Post Office(题目链接)。Post OfficeProblem DescriptionOther than postcards, the post office department of some country recognizes three classes of mailable items: letters, packets, and parcels. The three dimensions of a mailable item are called length, height and thickness, .. 阅读全文
posted @ 2012-10-03 00:38 叶剑飞Victor 阅读(973) 评论(0) 推荐(0) 编辑
摘要: 杭电OJ第4015题,Mario and Mushrooms(题目链接)。Mario and MushroomsProblem DescriptionMario usually relaxes himself by walking along the shady track near the Mushroom Kingdom. The evil King Koopa noticed that and placed a lot of mushroom on the road. There are two types of mushrooms, max mushrooms and bad mu.. 阅读全文
posted @ 2012-09-22 10:50 叶剑飞Victor 阅读(353) 评论(0) 推荐(0) 编辑
摘要: 杭电OJ第4011题,Working in Beijing(题目链接)。Working in BeijingProblem DescriptionMr. M is an undergraduate student of FDU. He finds an intern position in Beijing, so that he cannot attend all the college activities. But in some conditions, he must come back to Shanghai on certain date. We can assume the i.. 阅读全文
posted @ 2012-09-22 03:35 叶剑飞Victor 阅读(401) 评论(0) 推荐(0) 编辑
摘要: 杭电OJ第4018题,Parsing URL(题目链接)。Parsing URLProblem DescriptionIn computing, a Uniform Resource Locator or Universal Resource Locator (URL) is a character string that specifies where a known resource is available on the Internet and the mechanism for retrieving it.The syntax of a typical URL is:scheme.. 阅读全文
posted @ 2012-09-22 02:44 叶剑飞Victor 阅读(456) 评论(0) 推荐(0) 编辑
摘要: 吉林大学OJ第2775题,Problem F: Shadows(题目链接)。Problem F: Shadows“No sunshine but bath some shadow”. A shadow is an area where direct light from a light source cannot reach due to obstruction by an object. It occupies all of the space behind an opaque object with light in front of it.Let us consider a simp.. 阅读全文
posted @ 2012-08-19 19:33 叶剑飞Victor 阅读(942) 评论(0) 推荐(0) 编辑
摘要: NEUOJ第1155题,Mysterious Organization(题目链接)。Mysterious OrganizationDescriptionGFW had intercepted billions of illegal links successfully. It has much more effect. Today, GFW intercepted a message of a mysterious organization. This mysterious organization package the message in legitimate URL.To find.. 阅读全文
posted @ 2012-08-13 21:19 叶剑飞Victor 阅读(526) 评论(0) 推荐(0) 编辑
摘要: 杭电OJ第4255题,A Famous Grid(题目链接)。A Famous GridProblem DescriptionMr. B has recently discovered the grid named "spiral grid".Construct the grid like the following figure. (The grid is actually infinite. The figure is only a small part of it.)Considering traveling in it, you are free to any ce 阅读全文
posted @ 2012-08-13 19:57 叶剑飞Victor 阅读(425) 评论(0) 推荐(0) 编辑