ï»??xml version="1.0" encoding="utf-8" standalone="yes"?>欧美一级片一区,亚洲mv在线,日本不卡视频一区二区http://www.aygfsteel.com/zhaochengming/archive/2010/03/21/316045.htmlhelloworld2008helloworld2008Sat, 20 Mar 2010 17:14:00 GMThttp://www.aygfsteel.com/zhaochengming/archive/2010/03/21/316045.htmlhttp://www.aygfsteel.com/zhaochengming/comments/316045.htmlhttp://www.aygfsteel.com/zhaochengming/archive/2010/03/21/316045.html#Feedback0http://www.aygfsteel.com/zhaochengming/comments/commentRss/316045.htmlhttp://www.aygfsteel.com/zhaochengming/services/trackbacks/316045.html

KMP½Ž—法

KMP½Ž—法是一¿Uæ”¹˜q›çš„字符串匹配算法,此算法可以在O(n+m)的时间数量çñ”上完成串的模式匹配操作,基本思想是,每当匚w…˜q‡ç¨‹ä¸­å‡ºçް字½W¦ä¸²æ¯”较不等æ—Óž¼Œä¸éœ€å›žæº¯æŒ‡é’ˆåQŒè€Œæ˜¯åˆ©ç”¨å·²ç»å¾—到çš?#8220;部分匚w…”¾l“æžœž®†æ¨¡å¼å‘å?#8220;滑动”ž®½å¯èƒ½è¿œçš„一ŒDµè·¼›»ï¼Œæ®å¾˜q›è¡Œæ¯”较ã€?/font>

定义åQ?/font>

① 要搜索的关键字符ä¸?nbsp;key K1K2......Kmã€?/font>

② 被搜索的源字½W¦ä¸² source S1S2.....Snã€?/font>

针对要查扄¡š„关键字字½W¦ä¸²æž„造失效函数f(s)åQŒè¯¥å‡½æ•°çš„功能就是在比较å½?/font>K!= Sj的时候计½Ž—出从K的第多少个字½W¦å¼€å§‹é‡æ–°æ¯”较ã€?/font>

使得K1K2...Kf(s)是最长的既是K1K2...Ks的的真前¾~€åQŒåˆæ˜?/font>K1K2...Ks的后¾~€çš„å­—ä¸?/font>。也ž®±æ˜¯è¯´å¦‚果我们试囄¡”¨ä¸€ä¸ªæ–‡æœ¬ä¸²x匚w…K1K2......KmåQ?/font>òq¶ä¸”我们已经匚w…äº†å‰i个字½W¦ï¼Œä½†åŒ¹é…Ki+1的时候失败,也就是说x的下一个位¾|®ä¸æ˜¯Ki+1åQŒé‚£ä¹ˆf(s)ž®±æ˜¯å¯èƒ½å’Œæˆ‘们当前位¾|®äØ“¾l“尾的文本串匚w…çš„æœ€é•¿çš„K1K2......Km的前¾~€å’ŒåŽ¾~€y。也ž®±æ˜¯è¯´æ–‡æœ?/font>x的下一个位¾|®å’ŒKf(s)比较åQ?/font>X当前位置之前的f(s)个字½W¦å’ŒK1..Kf(s)是匹配的。所以直接从Kf(s)之后˜q›è¡Œæ¯”较ã€?/font>

½Ž—法如下åQ?/font>

t = 0;

f(1) = 0;

for (i = 1; i < m; i++) {

while(t > 0 && (Ki+1 != Kt+1)) t = f(t);

if(Ki+1 == Kt+1) {

t = t + 1;

f(i+1) = t;

} else f(i+1) = 0;

}

对于ä¸?/font>"a b a b a a"的计½Ž—f(s)的过½E‹å¦‚下:

s

f(s)

当前字符�/span>

说明

1

0

a

无真前缀

2

0

ab

无真前缀

3

1

aba

"a"æ˜?aba"的真前缀和后¾~€

4

2

abab

"ab"æ˜?abab"的真前缀和后¾~€

5

3

ababa

"aba"æ˜?ababa"的真前缀和后¾~€

6

1

ababaa

"a"æ˜?ababaa"的真前缀和后¾~€

针检�/font>S1S2.....Sn是否包含关键�/font>K1K2......Km的算�/font>�/font>

s = 0;

for (i = 1; i <= n i++) {   // ä¸‹æ ‡ä»?å¼€å§?/font>

while (s > 0 && Si != Ks+1) s = f(s);

if(Si == Ks+1) s = s + 1;

if(s == n) return "yes";

}

return "no";



]]>
文法的化½Ž€ä¸Žæ”¹é€?/title><link>http://www.aygfsteel.com/zhaochengming/archive/2009/07/06/285613.html</link><dc:creator>helloworld2008</dc:creator><author>helloworld2008</author><pubDate>Sun, 05 Jul 2009 16:45:00 GMT</pubDate><guid>http://www.aygfsteel.com/zhaochengming/archive/2009/07/06/285613.html</guid><wfw:comment>http://www.aygfsteel.com/zhaochengming/comments/285613.html</wfw:comment><comments>http://www.aygfsteel.com/zhaochengming/archive/2009/07/06/285613.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.aygfsteel.com/zhaochengming/comments/commentRss/285613.html</wfw:commentRss><trackback:ping>http://www.aygfsteel.com/zhaochengming/services/trackbacks/285613.html</trackback:ping><description><![CDATA[<p class="p0" style="margin-top: 0pt; margin-bottom: 0pt"><span style="font-weight: normal; font-size: 14pt; font-family: '宋体'; mso-spacerun: 'yes'">文法的化½Ž€ä¸Žæ”¹é€?/span><span style="font-weight: normal; font-size: 14pt; font-family: '宋体'; mso-spacerun: 'yes'"><o:p></o:p></span></p> <p class="p0" style="margin-top: 0pt; margin-bottom: 0pt"><span style="font-weight: normal; font-size: 14pt; color: rgb(0,0,255); font-family: '宋体'; mso-spacerun: 'yes'">1、无用符号及无用产生式的删除 </span><span style="font-weight: normal; font-size: 14pt; font-family: '宋体'; mso-spacerun: 'yes'"><o:p></o:p></span></p> <p class="p0" style="margin-top: 0pt; margin-bottom: 0pt"><span style="font-weight: normal; font-size: 14pt; font-family: '宋体'; mso-spacerun: 'yes'">无用½W¦å·åQšè®¾æœ‰ä¸€æ–‡æ³•G[S]= åQˆV</span><span style="font-weight: normal; font-size: 14pt; vertical-align: sub; font-family: '宋体'; mso-spacerun: 'yes'">N</span><span style="font-weight: normal; font-size: 14pt; font-family: '宋体'; mso-spacerun: 'yes'"> åQŒV</span><span style="font-weight: normal; font-size: 14pt; vertical-align: sub; font-family: '宋体'; mso-spacerun: 'yes'">T</span><span style="font-weight: normal; font-size: 14pt; font-family: '宋体'; mso-spacerun: 'yes'"> åQŒPåQŒSåQ‰ï¼Œè¯´G中的一个符号X∈V是有用的是指X臛_°‘出现在一个句子的推导˜q‡ç¨‹ä¸­ï¼ŒåÏx»¡­‘»I¼š</span><span style="font-weight: normal; font-size: 14pt; font-family: '宋体'; mso-spacerun: 'yes'"><o:p></o:p></span></p> <p class="p0" style="margin-top: 0pt; margin-bottom: 0pt"><span style="font-weight: normal; font-size: 14pt; font-family: '宋体'; mso-spacerun: 'yes'">存在αåQ?#946;∈V*åQŒæœ‰S=*>αXβ </span><span style="font-weight: normal; font-size: 14pt; font-family: '宋体'; mso-spacerun: 'yes'"><o:p></o:p></span></p> <p class="p0" style="margin-top: 0pt; margin-bottom: 0pt"><span style="font-weight: normal; font-size: 14pt; font-family: '宋体'; mso-spacerun: 'yes'">存在ω∈V</span><span style="font-weight: normal; font-size: 14pt; vertical-align: sub; font-family: '宋体'; mso-spacerun: 'yes'">T</span><span style="font-weight: normal; font-size: 14pt; font-family: '宋体'; mso-spacerun: 'yes'">* åQ?#945;Xβ=*>ω</span><span style="font-weight: normal; font-size: 14pt; font-family: '宋体'; mso-spacerun: 'yes'"><o:p></o:p></span></p> <p class="p0" style="margin-top: 0pt; margin-bottom: 0pt"><span style="font-weight: normal; font-size: 14pt; font-family: '宋体'; mso-spacerun: 'yes'">否则X为无用符å?/span><span style="font-weight: normal; font-size: 14pt; font-family: '宋体'; mso-spacerun: 'yes'"><o:p></o:p></span></p> <p class="p0" style="margin-top: 0pt; margin-bottom: 0pt"><span style="font-weight: normal; font-size: 14pt; font-family: '宋体'; mso-spacerun: 'yes'">设有文法G[S]= åQˆV</span><span style="font-weight: normal; font-size: 14pt; vertical-align: sub; font-family: '宋体'; mso-spacerun: 'yes'">N</span><span style="font-weight: normal; font-size: 14pt; font-family: '宋体'; mso-spacerun: 'yes'"> åQŒV</span><span style="font-weight: normal; font-size: 14pt; vertical-align: sub; font-family: '宋体'; mso-spacerun: 'yes'">T</span><span style="font-weight: normal; font-size: 14pt; font-family: '宋体'; mso-spacerun: 'yes'"> åQŒPåQŒSåQ‰ï¼Œé¦–先用算æ³?.1攚w€ è¯¥æ–‡æ³•的到G1[S]= åQˆV</span><span style="font-weight: normal; font-size: 14pt; vertical-align: sub; font-family: '宋体'; mso-spacerun: 'yes'">N1</span><span style="font-weight: normal; font-size: 14pt; font-family: '宋体'; mso-spacerun: 'yes'"> åQŒV</span><span style="font-weight: normal; font-size: 14pt; vertical-align: sub; font-family: '宋体'; mso-spacerun: 'yes'">T</span><span style="font-weight: normal; font-size: 14pt; font-family: '宋体'; mso-spacerun: 'yes'"> åQŒP</span><span style="font-weight: normal; font-size: 14pt; vertical-align: sub; font-family: '宋体'; mso-spacerun: 'yes'">1</span><span style="font-weight: normal; font-size: 14pt; font-family: '宋体'; mso-spacerun: 'yes'">åQŒSåQ‰ï¼Œä½¿å¾—对于每一个X∈V</span><span style="font-weight: normal; font-size: 14pt; vertical-align: sub; font-family: '宋体'; mso-spacerun: 'yes'">N1</span><span style="font-weight: normal; font-size: 14pt; font-family: '宋体'; mso-spacerun: 'yes'">åQŒéƒ½æœ?#969;∈V</span><span style="font-weight: normal; font-size: 14pt; vertical-align: sub; font-family: '宋体'; mso-spacerun: 'yes'">T</span><span style="font-weight: normal; font-size: 14pt; font-family: '宋体'; mso-spacerun: 'yes'">*åQŒX=*>ω</span><span style="font-weight: normal; font-size: 14pt; font-family: '宋体'; mso-spacerun: 'yes'"><o:p></o:p></span></p> <p class="p0" style="margin-top: 0pt; margin-bottom: 0pt"><span style="font-weight: normal; font-size: 14pt; color: rgb(255,0,0); font-family: '宋体'; mso-spacerun: 'yes'">½Ž—法1åQ?nbsp;</span><span style="font-weight: normal; font-size: 14pt; font-family: '宋体'; mso-spacerun: 'yes'"><o:p></o:p></span></p> <p class="p0" style="margin-top: 0pt; margin-bottom: 0pt"><span style="font-weight: normal; font-size: 14pt; font-family: '宋体'; mso-spacerun: 'yes'">(1) </span><span style="font-weight: normal; font-size: 14pt; font-family: '宋体'; mso-spacerun: 'yes'">分别¾|®V</span><span style="font-weight: normal; font-size: 14pt; vertical-align: sub; font-family: '宋体'; mso-spacerun: 'yes'">N1</span><span style="font-weight: normal; font-size: 14pt; font-family: '宋体'; mso-spacerun: 'yes'">åQŒP</span><span style="font-weight: normal; font-size: 14pt; vertical-align: sub; font-family: '宋体'; mso-spacerun: 'yes'">1</span><span style="font-weight: normal; font-size: 14pt; font-family: '宋体'; mso-spacerun: 'yes'">ä¸?#934;ã€?/span><span style="font-weight: normal; font-size: 14pt; font-family: '宋体'; mso-spacerun: 'yes'"><o:p></o:p></span></p> <p class="p0" style="margin-top: 0pt; margin-bottom: 0pt"><span style="font-weight: normal; font-size: 14pt; font-family: '宋体'; mso-spacerun: 'yes'">(2) </span><span style="font-weight: normal; font-size: 14pt; font-family: '宋体'; mso-spacerun: 'yes'">对P中每一个äñ”生式A→δåQŒè‹¥δ∈V</span><span style="font-weight: normal; font-size: 14pt; vertical-align: sub; font-family: '宋体'; mso-spacerun: 'yes'">T</span><span style="font-weight: normal; font-size: 14pt; font-family: '宋体'; mso-spacerun: 'yes'">*åQŒåˆ™ž®†A攑օ¥V</span><span style="font-weight: normal; font-size: 14pt; vertical-align: sub; font-family: '宋体'; mso-spacerun: 'yes'">N1</span><span style="font-weight: normal; font-size: 14pt; font-family: '宋体'; mso-spacerun: 'yes'">中ã€?/span><span style="font-weight: normal; font-size: 14pt; font-family: '宋体'; mso-spacerun: 'yes'"><o:p></o:p></span></p> <p class="p0" style="margin-top: 0pt; margin-bottom: 0pt"><span style="font-weight: normal; font-size: 14pt; font-family: '宋体'; mso-spacerun: 'yes'">(3) </span><span style="font-weight: normal; font-size: 14pt; font-family: '宋体'; mso-spacerun: 'yes'">对P中每一个äñ”生式A→X</span><span style="font-weight: normal; font-size: 14pt; vertical-align: sub; font-family: '宋体'; mso-spacerun: 'yes'">1</span><span style="font-weight: normal; font-size: 14pt; font-family: '宋体'; mso-spacerun: 'yes'"> X</span><span style="font-weight: normal; font-size: 14pt; vertical-align: sub; font-family: '宋体'; mso-spacerun: 'yes'">2</span><span style="font-weight: normal; font-size: 14pt; font-family: '宋体'; mso-spacerun: 'yes'">……X</span><span style="font-weight: normal; font-size: 14pt; vertical-align: sub; font-family: '宋体'; mso-spacerun: 'yes'">K</span><span style="font-weight: normal; font-size: 14pt; font-family: '宋体'; mso-spacerun: 'yes'">åQŒè‹¥æ¯ä¸€ä¸ªX</span><span style="font-weight: normal; font-size: 14pt; vertical-align: sub; font-family: '宋体'; mso-spacerun: 'yes'">i</span><span style="font-weight: normal; font-size: 14pt; font-family: '宋体'; mso-spacerun: 'yes'"> éƒ½å±žäºŽV</span><span style="font-weight: normal; font-size: 14pt; vertical-align: sub; font-family: '宋体'; mso-spacerun: 'yes'">T</span><span style="font-weight: normal; font-size: 14pt; font-family: '宋体'; mso-spacerun: 'yes'">或V</span><span style="font-weight: normal; font-size: 14pt; vertical-align: sub; font-family: '宋体'; mso-spacerun: 'yes'">N1</span><span style="font-weight: normal; font-size: 14pt; font-family: '宋体'; mso-spacerun: 'yes'">åQŒåˆ™ž®†A攑օ¥V</span><span style="font-weight: normal; font-size: 14pt; vertical-align: sub; font-family: '宋体'; mso-spacerun: 'yes'">N1</span><span style="font-weight: normal; font-size: 14pt; font-family: '宋体'; mso-spacerun: 'yes'">中ã€?/span><span style="font-weight: normal; font-size: 14pt; font-family: '宋体'; mso-spacerun: 'yes'"><o:p></o:p></span></p> <p class="p0" style="margin-top: 0pt; margin-bottom: 0pt"><span style="font-weight: normal; font-size: 14pt; font-family: '宋体'; mso-spacerun: 'yes'">(4) </span><span style="font-weight: normal; font-size: 14pt; font-family: '宋体'; mso-spacerun: 'yes'">重复③直至V</span><span style="font-weight: normal; font-size: 14pt; vertical-align: sub; font-family: '宋体'; mso-spacerun: 'yes'">N1</span><span style="font-weight: normal; font-size: 14pt; font-family: '宋体'; mso-spacerun: 'yes'">不增大ã€?/span><span style="font-weight: normal; font-size: 14pt; font-family: '宋体'; mso-spacerun: 'yes'"><o:p></o:p></span></p> <p class="p0" style="margin-top: 0pt; margin-bottom: 0pt"><span style="font-weight: normal; font-size: 14pt; font-family: '宋体'; mso-spacerun: 'yes'">(5) </span><span style="font-weight: normal; font-size: 14pt; font-family: '宋体'; mso-spacerun: 'yes'">对于P中的每一个äñ”生式B→Y</span><span style="font-weight: normal; font-size: 14pt; vertical-align: sub; font-family: '宋体'; mso-spacerun: 'yes'">1</span><span style="font-weight: normal; font-size: 14pt; font-family: '宋体'; mso-spacerun: 'yes'"> Y</span><span style="font-weight: normal; font-size: 14pt; vertical-align: sub; font-family: '宋体'; mso-spacerun: 'yes'">2</span><span style="font-weight: normal; font-size: 14pt; font-family: '宋体'; mso-spacerun: 'yes'">……Y</span><span style="font-weight: normal; font-size: 14pt; vertical-align: sub; font-family: '宋体'; mso-spacerun: 'yes'">n</span><span style="font-weight: normal; font-size: 14pt; font-family: '宋体'; mso-spacerun: 'yes'"> åQŒè‹¥B及每一个Y</span><span style="font-weight: normal; font-size: 14pt; vertical-align: sub; font-family: '宋体'; mso-spacerun: 'yes'">i</span><span style="font-weight: normal; font-size: 14pt; font-family: '宋体'; mso-spacerun: 'yes'"> åQŒéƒ½å±žäºŽV</span><span style="font-weight: normal; font-size: 14pt; vertical-align: sub; font-family: '宋体'; mso-spacerun: 'yes'">N1</span><span style="font-weight: normal; font-size: 14pt; font-family: '宋体'; mso-spacerun: 'yes'">∪V</span><span style="font-weight: normal; font-size: 14pt; vertical-align: sub; font-family: '宋体'; mso-spacerun: 'yes'">T</span><span style="font-weight: normal; font-size: 14pt; font-family: '宋体'; mso-spacerun: 'yes'">  åQŒåˆ™ž®†B→Y</span><span style="font-weight: normal; font-size: 14pt; vertical-align: sub; font-family: '宋体'; mso-spacerun: 'yes'">1</span><span style="font-weight: normal; font-size: 14pt; font-family: '宋体'; mso-spacerun: 'yes'"> Y</span><span style="font-weight: normal; font-size: 14pt; vertical-align: sub; font-family: '宋体'; mso-spacerun: 'yes'">2</span><span style="font-weight: normal; font-size: 14pt; font-family: '宋体'; mso-spacerun: 'yes'">……Y</span><span style="font-weight: normal; font-size: 14pt; vertical-align: sub; font-family: '宋体'; mso-spacerun: 'yes'">n</span><span style="font-weight: normal; font-size: 14pt; font-family: '宋体'; mso-spacerun: 'yes'">åQŒæ”¾å…¥P</span><span style="font-weight: normal; font-size: 14pt; vertical-align: sub; font-family: '宋体'; mso-spacerun: 'yes'">1</span><span style="font-weight: normal; font-size: 14pt; font-family: '宋体'; mso-spacerun: 'yes'">中ã€?nbsp;</span><span style="font-weight: normal; font-size: 14pt; font-family: '宋体'; mso-spacerun: 'yes'"><o:p></o:p></span></p> <p class="p0" style="margin-top: 0pt; margin-bottom: 0pt"><span style="font-weight: normal; font-size: 14pt; font-family: '宋体'; mso-spacerun: 'yes'">其次åQŒå¯¹ä»¥ç»™æ–‡æ³•G[S]åQŒè‹¥æ‰§è¡Œ½Ž—法2.2可得åˆîC¸€½{‰ä­h文法G’=åQˆV</span><span style="font-weight: normal; font-size: 14pt; vertical-align: sub; font-family: '宋体'; mso-spacerun: 'yes'">N</span><span style="font-weight: normal; font-size: 14pt; font-family: '宋体'; mso-spacerun: 'yes'">’åQ?nbsp;V</span><span style="font-weight: normal; font-size: 14pt; vertical-align: sub; font-family: '宋体'; mso-spacerun: 'yes'">T</span><span style="font-weight: normal; font-size: 14pt; font-family: '宋体'; mso-spacerun: 'yes'">’ åQŒP’åQŒSåQ‰ä‹É得对ä»ÖM¸€X∈V</span><span style="font-weight: normal; font-size: 14pt; vertical-align: sub; font-family: '宋体'; mso-spacerun: 'yes'">N</span><span style="font-weight: normal; font-size: 14pt; font-family: '宋体'; mso-spacerun: 'yes'">’∪ V</span><span style="font-weight: normal; font-size: 14pt; vertical-align: sub; font-family: '宋体'; mso-spacerun: 'yes'">T</span><span style="font-weight: normal; font-size: 14pt; font-family: '宋体'; mso-spacerun: 'yes'">’都存åœ?#945;åQ?#946;∈åQˆV</span><span style="font-weight: normal; font-size: 14pt; vertical-align: sub; font-family: '宋体'; mso-spacerun: 'yes'">N</span><span style="font-weight: normal; font-size: 14pt; font-family: '宋体'; mso-spacerun: 'yes'">’∪ V</span><span style="font-weight: normal; font-size: 14pt; vertical-align: sub; font-family: '宋体'; mso-spacerun: 'yes'">T</span><span style="font-weight: normal; font-size: 14pt; font-family: '宋体'; mso-spacerun: 'yes'">’åQ‰æœ‰S=*>αXβ. </span><span style="font-weight: normal; font-size: 14pt; font-family: '宋体'; mso-spacerun: 'yes'"><o:p></o:p></span></p> <p class="p0" style="margin-top: 0pt; margin-bottom: 0pt"><span style="font-weight: normal; font-size: 14pt; font-family: '宋体'; mso-spacerun: 'yes'"><o:p></o:p></span></p> <p class="p0" style="margin-top: 0pt; margin-bottom: 0pt"><span style="font-weight: normal; font-size: 14pt; color: rgb(255,0,0); font-family: '宋体'; mso-spacerun: 'yes'">½Ž—法2:</span><span style="font-weight: normal; font-size: 14pt; font-family: '宋体'; mso-spacerun: 'yes'"><o:p></o:p></span></p> <p class="p0" style="margin-top: 0pt; margin-bottom: 0pt"><span style="font-weight: normal; font-size: 14pt; font-family: '宋体'; mso-spacerun: 'yes'">1.分别¾|®V</span><span style="font-weight: normal; font-size: 14pt; vertical-align: sub; font-family: '宋体'; mso-spacerun: 'yes'">N</span><span style="font-weight: normal; font-size: 14pt; font-family: '宋体'; mso-spacerun: 'yes'">’ã€?nbsp;V</span><span style="font-weight: normal; font-size: 14pt; vertical-align: sub; font-family: '宋体'; mso-spacerun: 'yes'">T</span><span style="font-weight: normal; font-size: 14pt; font-family: '宋体'; mso-spacerun: 'yes'">’、P’ä¸?#966;</span><span style="font-weight: normal; font-size: 14pt; font-family: '宋体'; mso-spacerun: 'yes'"><o:p></o:p></span></p> <p class="p0" style="margin-top: 0pt; margin-bottom: 0pt"><span style="font-weight: normal; font-size: 14pt; font-family: '宋体'; mso-spacerun: 'yes'">2.ž®†S æ”‘Ö…¥V</span><span style="font-weight: normal; font-size: 14pt; vertical-align: sub; font-family: '宋体'; mso-spacerun: 'yes'">N</span><span style="font-weight: normal; font-size: 14pt; font-family: '宋体'; mso-spacerun: 'yes'">’中ã€?/span><span style="font-weight: normal; font-size: 14pt; font-family: '宋体'; mso-spacerun: 'yes'"><o:p></o:p></span></p> <p class="p0" style="margin-top: 0pt; margin-bottom: 0pt"><span style="font-weight: normal; font-size: 14pt; font-family: '宋体'; mso-spacerun: 'yes'">3.对于G中ä“Q何型如A→α</span><span style="font-weight: normal; font-size: 14pt; vertical-align: sub; font-family: '宋体'; mso-spacerun: 'yes'">1</span><span style="font-weight: normal; font-size: 14pt; font-family: '宋体'; mso-spacerun: 'yes'">|……|α</span><span style="font-weight: normal; font-size: 14pt; vertical-align: sub; font-family: '宋体'; mso-spacerun: 'yes'">m</span><span style="font-weight: normal; font-size: 14pt; font-family: '宋体'; mso-spacerun: 'yes'">çš„äñ”生式åQŒè‹¥A∈V</span><span style="font-weight: normal; font-size: 14pt; vertical-align: sub; font-family: '宋体'; mso-spacerun: 'yes'">N</span><span style="font-weight: normal; font-size: 14pt; font-family: '宋体'; mso-spacerun: 'yes'">’则将α</span><span style="font-weight: normal; font-size: 14pt; vertical-align: sub; font-family: '宋体'; mso-spacerun: 'yes'">1</span><span style="font-weight: normal; font-size: 14pt; font-family: '宋体'; mso-spacerun: 'yes'">……α</span><span style="font-weight: normal; font-size: 14pt; vertical-align: sub; font-family: '宋体'; mso-spacerun: 'yes'">m</span><span style="font-weight: normal; font-size: 14pt; font-family: '宋体'; mso-spacerun: 'yes'"> ä¸­çš„全部非终¾l“符攑օ¥V</span><span style="font-weight: normal; font-size: 14pt; vertical-align: sub; font-family: '宋体'; mso-spacerun: 'yes'">N</span><span style="font-weight: normal; font-size: 14pt; font-family: '宋体'; mso-spacerun: 'yes'">’中,¾lˆç»“½W¦æ”¾å…¥V</span><span style="font-weight: normal; font-size: 14pt; vertical-align: sub; font-family: '宋体'; mso-spacerun: 'yes'">T</span><span style="font-weight: normal; font-size: 14pt; font-family: '宋体'; mso-spacerun: 'yes'">’中ã€?/span><span style="font-weight: normal; font-size: 14pt; font-family: '宋体'; mso-spacerun: 'yes'"><o:p></o:p></span></p> <p class="p0" style="margin-top: 0pt; margin-bottom: 0pt"><span style="font-weight: normal; font-size: 14pt; font-family: '宋体'; mso-spacerun: 'yes'">4.重复③直至V</span><span style="font-weight: normal; font-size: 14pt; vertical-align: sub; font-family: '宋体'; mso-spacerun: 'yes'">N</span><span style="font-weight: normal; font-size: 14pt; font-family: '宋体'; mso-spacerun: 'yes'">’ã€?nbsp;V</span><span style="font-weight: normal; font-size: 14pt; vertical-align: sub; font-family: '宋体'; mso-spacerun: 'yes'">T</span><span style="font-weight: normal; font-size: 14pt; font-family: '宋体'; mso-spacerun: 'yes'">’ä¸å¢žå¤§äØ“æ­¢ã€?/span><span style="font-weight: normal; font-size: 14pt; font-family: '宋体'; mso-spacerun: 'yes'"><o:p></o:p></span></p> <p class="p0" style="margin-top: 0pt; margin-bottom: 0pt"><span style="font-weight: normal; font-size: 14pt; font-family: '宋体'; mso-spacerun: 'yes'">5.ž®†P中左右部仅含V</span><span style="font-weight: normal; font-size: 14pt; vertical-align: sub; font-family: '宋体'; mso-spacerun: 'yes'">N</span><span style="font-weight: normal; font-size: 14pt; font-family: '宋体'; mso-spacerun: 'yes'">’∪ V</span><span style="font-weight: normal; font-size: 14pt; vertical-align: sub; font-family: '宋体'; mso-spacerun: 'yes'">T</span><span style="font-weight: normal; font-size: 14pt; font-family: '宋体'; mso-spacerun: 'yes'">’中符åïLš„æ‰€æœ‰äñ”生式攑օ¥P’ ä¸­ã€?nbsp;</span><span style="font-weight: normal; font-size: 14pt; font-family: '宋体'; mso-spacerun: 'yes'"><o:p></o:p></span></p> <p class="p0" style="margin-top: 0pt; margin-bottom: 0pt"><span style="font-weight: normal; font-size: 14pt; font-family: '宋体'; mso-spacerun: 'yes'"> </span><span style="font-weight: normal; font-size: 14pt; font-family: '宋体'; mso-spacerun: 'yes'"><o:p></o:p></span></p> <p class="p0" style="margin-top: 0pt; margin-bottom: 0pt"><span style="font-weight: normal; font-size: 14pt; font-family: '宋体'; mso-spacerun: 'yes'"><o:p></o:p></span></p> <p class="p0" style="margin-top: 0pt; margin-bottom: 0pt"><span style="font-weight: normal; font-size: 14pt; color: rgb(0,0,255); font-family: '宋体'; mso-spacerun: 'yes'">2ã€?#949;—äñ”生式的消é™?/span><span style="font-weight: normal; font-size: 14pt; font-family: '宋体'; mso-spacerun: 'yes'"><o:p></o:p></span></p> <p class="p0" style="margin-top: 0pt; margin-bottom: 0pt"><span style="font-weight: normal; font-size: 14pt; font-family: '宋体'; mso-spacerun: 'yes'">有的分析æ–ÒŽ³•要求文法中不能含æœ?#949;—äñ”生式åQŒå› æ­¤éœ€è¦æ”¹é€ æ–‡æ³•ä‹É之不å?#949;—äñ”生式ã€?/span><span style="font-weight: normal; font-size: 14pt; font-family: '宋体'; mso-spacerun: 'yes'"><o:p></o:p></span></p> <p class="p0" style="margin-top: 0pt; margin-bottom: 0pt"><span style="font-weight: normal; font-size: 14pt; font-family: '宋体'; mso-spacerun: 'yes'">如果语言不含æœ?#949;句子åQŒåˆ™å¯æœ‰åŠžæ³•æ¶ˆé™¤æ–‡æ³•ä¸­çš„å…¨éƒ¨ε—äñ”生式åQŒå¦åˆ™ä¸å¯èƒ½å…¨éƒ¨æ¶ˆé™¤åQŒä½†æˆ‘们希望只有在空句子的推å¯ég¸­ç”¨åˆ°ε—äñ”生式åQŒå…¶ä»–语句的推导˜q‡ç¨‹ä¸­ä¸ä¼šä‹Éç”?#949;—äñ”生式。故对含有空句子的文法,我们希望只有文法开始符S→ε˜q™æ ·ä¸€ä¸ªäñ”生式òq¶ä¸”S不出现在其它ä»ÖM½•产生式的右部ã€?/span><span style="font-weight: normal; font-size: 14pt; font-family: '宋体'; mso-spacerun: 'yes'"><o:p></o:p></span></p> <p class="p0" style="margin-top: 0pt; margin-bottom: 0pt"><span style="font-weight: normal; font-size: 14pt; color: rgb(255,0,0); font-family: '宋体'; mso-spacerun: 'yes'">½Ž—法3åQ?/span><span style="font-weight: normal; font-size: 14pt; font-family: '宋体'; mso-spacerun: 'yes'"><o:p></o:p></span></p> <p class="p0" style="margin-top: 0pt; margin-bottom: 0pt"><span style="font-weight: normal; font-size: 14pt; font-family: '宋体'; mso-spacerun: 'yes'">扑ևºæ‰€æœ‰èƒ½å¯¼å‡ºε的非¾lˆç»“½W¦ã€?/span><span style="font-weight: normal; font-size: 14pt; font-family: '宋体'; mso-spacerun: 'yes'"><o:p></o:p></span></p> <p class="p0" style="margin-top: 0pt; margin-bottom: 0pt"><span style="font-weight: normal; font-size: 14pt; font-family: '宋体'; mso-spacerun: 'yes'">1.构造W</span><span style="font-weight: normal; font-size: 14pt; vertical-align: sub; font-family: '宋体'; mso-spacerun: 'yes'">1</span><span style="font-weight: normal; font-size: 14pt; font-family: '宋体'; mso-spacerun: 'yes'">={A|产生式A→ε∈P}</span><span style="font-weight: normal; font-size: 14pt; font-family: '宋体'; mso-spacerun: 'yes'"><o:p></o:p></span></p> <p class="p0" style="margin-top: 0pt; margin-bottom: 0pt"><span style="font-weight: normal; font-size: 14pt; font-family: '宋体'; mso-spacerun: 'yes'">2.构造集合序列W</span><span style="font-weight: normal; font-size: 14pt; vertical-align: sub; font-family: '宋体'; mso-spacerun: 'yes'">K+1</span><span style="font-weight: normal; font-size: 14pt; font-family: '宋体'; mso-spacerun: 'yes'">= W</span><span style="font-weight: normal; font-size: 14pt; vertical-align: sub; font-family: '宋体'; mso-spacerun: 'yes'">K</span><span style="font-weight: normal; font-size: 14pt; font-family: '宋体'; mso-spacerun: 'yes'">∪{B|B→β∈PåQŒä¸”β∈W</span><span style="font-weight: normal; font-size: 14pt; vertical-align: sub; font-family: '宋体'; mso-spacerun: 'yes'">K</span><span style="font-weight: normal; font-size: 14pt; font-family: '宋体'; mso-spacerun: 'yes'">åQŒK≥1}</span><span style="font-weight: normal; font-size: 14pt; font-family: '宋体'; mso-spacerun: 'yes'"><o:p></o:p></span></p> <p class="p0" style="margin-top: 0pt; margin-bottom: 0pt"><span style="font-weight: normal; font-size: 14pt; font-family: '宋体'; mso-spacerun: 'yes'">  W</span><span style="font-weight: normal; font-size: 14pt; vertical-align: sub; font-family: '宋体'; mso-spacerun: 'yes'">K+1</span><span style="font-weight: normal; font-size: 14pt; font-family: '宋体'; mso-spacerun: 'yes'">是一个有限集åQŒè®¾æœ€åŽçš„W</span><span style="font-weight: normal; font-size: 14pt; vertical-align: sub; font-family: '宋体'; mso-spacerun: 'yes'">K+1</span><span style="font-weight: normal; font-size: 14pt; font-family: '宋体'; mso-spacerun: 'yes'">为Wã€?/span><span style="font-weight: normal; font-size: 14pt; font-family: '宋体'; mso-spacerun: 'yes'"><o:p></o:p></span></p> <p class="p0" style="margin-top: 0pt; margin-bottom: 0pt"><span style="font-weight: normal; font-size: 14pt; font-family: '宋体'; mso-spacerun: 'yes'">当S∈Wæ—Óž¼Œε∈LåQˆG[S]åQ‰ã€?/span><span style="font-weight: normal; font-size: 14pt; font-family: '宋体'; mso-spacerun: 'yes'"><o:p></o:p></span></p> <p class="p0" style="margin-top: 0pt; margin-bottom: 0pt"><span style="font-weight: normal; font-size: 14pt; font-family: '宋体'; mso-spacerun: 'yes'">设有一文法G[S]= åQˆV</span><span style="font-weight: normal; font-size: 14pt; vertical-align: sub; font-family: '宋体'; mso-spacerun: 'yes'">N</span><span style="font-weight: normal; font-size: 14pt; font-family: '宋体'; mso-spacerun: 'yes'"> åQŒV</span><span style="font-weight: normal; font-size: 14pt; vertical-align: sub; font-family: '宋体'; mso-spacerun: 'yes'">T</span><span style="font-weight: normal; font-size: 14pt; font-family: '宋体'; mso-spacerun: 'yes'"> åQŒPåQŒSåQ‰ï¼Œå½?#949;不属于该文法所描述的语­a€æ—Óž¼Œå¯æž„造文法:</span><span style="font-weight: normal; font-size: 14pt; font-family: '宋体'; mso-spacerun: 'yes'"><o:p></o:p></span></p> <p class="p0" style="margin-top: 0pt; margin-bottom: 0pt"><span style="font-weight: normal; font-size: 14pt; font-family: '宋体'; mso-spacerun: 'yes'">G’=åQˆV</span><span style="font-weight: normal; font-size: 14pt; vertical-align: sub; font-family: '宋体'; mso-spacerun: 'yes'">N</span><span style="font-weight: normal; font-size: 14pt; font-family: '宋体'; mso-spacerun: 'yes'">åQŒV</span><span style="font-weight: normal; font-size: 14pt; vertical-align: sub; font-family: '宋体'; mso-spacerun: 'yes'">T</span><span style="font-weight: normal; font-size: 14pt; font-family: '宋体'; mso-spacerun: 'yes'">åQŒP’åQŒSåQ‰ï¼Œä½¿å¾—LåQˆG’åQ?LåQˆGåQ‰ï¼ŒG’不含æœ?#949;产生式:</span><span style="font-weight: normal; font-size: 14pt; font-family: '宋体'; mso-spacerun: 'yes'"><o:p></o:p></span></p> <p class="p0" style="margin-top: 0pt; margin-bottom: 0pt"><span style="font-weight: normal; font-size: 14pt; color: rgb(255,0,0); font-family: '宋体'; mso-spacerun: 'yes'">½Ž—法4:</span><span style="font-weight: normal; font-size: 14pt; font-family: '宋体'; mso-spacerun: 'yes'"><o:p></o:p></span></p> <p class="p0" style="margin-top: 0pt; margin-bottom: 0pt"><span style="font-weight: normal; font-size: 14pt; font-family: '宋体'; mso-spacerun: 'yes'">1.利用Wž®†V</span><span style="font-weight: normal; font-size: 14pt; vertical-align: sub; font-family: '宋体'; mso-spacerun: 'yes'">N</span><span style="font-weight: normal; font-size: 14pt; font-family: '宋体'; mso-spacerun: 'yes'"> åˆ†äؓ两个子集W及V</span><span style="font-weight: normal; font-size: 14pt; vertical-align: sub; font-family: '宋体'; mso-spacerun: 'yes'">N</span><span style="font-weight: normal; font-size: 14pt; font-family: '宋体'; mso-spacerun: 'yes'"> -Wã€?/span><span style="font-weight: normal; font-size: 14pt; font-family: '宋体'; mso-spacerun: 'yes'"><o:p></o:p></span></p> <p class="p0" style="margin-top: 0pt; margin-bottom: 0pt"><span style="font-weight: normal; font-size: 14pt; font-family: '宋体'; mso-spacerun: 'yes'">2.设A→X</span><span style="font-weight: normal; font-size: 14pt; vertical-align: sub; font-family: '宋体'; mso-spacerun: 'yes'">1</span><span style="font-weight: normal; font-size: 14pt; font-family: '宋体'; mso-spacerun: 'yes'"> X</span><span style="font-weight: normal; font-size: 14pt; vertical-align: sub; font-family: '宋体'; mso-spacerun: 'yes'">2</span><span style="font-weight: normal; font-size: 14pt; font-family: '宋体'; mso-spacerun: 'yes'">……X</span><span style="font-weight: normal; font-size: 14pt; vertical-align: sub; font-family: '宋体'; mso-spacerun: 'yes'">K</span><span style="font-weight: normal; font-size: 14pt; font-family: '宋体'; mso-spacerun: 'yes'">∈PåQŒæŒ‰ä¸‹é¢è§„则ž®†æ‰€æœ‰åž‹å¦‚A→Y</span><span style="font-weight: normal; font-size: 14pt; vertical-align: sub; font-family: '宋体'; mso-spacerun: 'yes'">1</span><span style="font-weight: normal; font-size: 14pt; font-family: '宋体'; mso-spacerun: 'yes'"> Y</span><span style="font-weight: normal; font-size: 14pt; vertical-align: sub; font-family: '宋体'; mso-spacerun: 'yes'">2</span><span style="font-weight: normal; font-size: 14pt; font-family: '宋体'; mso-spacerun: 'yes'">……Y</span><span style="font-weight: normal; font-size: 14pt; vertical-align: sub; font-family: '宋体'; mso-spacerun: 'yes'">K</span><span style="font-weight: normal; font-size: 14pt; font-family: '宋体'; mso-spacerun: 'yes'"> çš„äñ”生式攑օ¥P’中,对于一åˆ?≤i≤kåQ?/span><span style="font-weight: normal; font-size: 14pt; font-family: '宋体'; mso-spacerun: 'yes'"><o:p></o:p></span></p> <p class="p0" style="margin-top: 0pt; margin-bottom: 0pt"><span style="font-weight: normal; font-size: 14pt; font-family: '宋体'; mso-spacerun: 'yes'">  aåQŽè‹¥X</span><span style="font-weight: normal; font-size: 14pt; vertical-align: sub; font-family: '宋体'; mso-spacerun: 'yes'">i</span><span style="font-weight: normal; font-size: 14pt; font-family: '宋体'; mso-spacerun: 'yes'"> ä¸å±žäºŽWåQŒåˆ™å–Y</span><span style="font-weight: normal; font-size: 14pt; vertical-align: sub; font-family: '宋体'; mso-spacerun: 'yes'">i</span><span style="font-weight: normal; font-size: 14pt; font-family: '宋体'; mso-spacerun: 'yes'"> = X</span><span style="font-weight: normal; font-size: 14pt; vertical-align: sub; font-family: '宋体'; mso-spacerun: 'yes'">i</span><span style="font-weight: normal; font-size: 14pt; font-family: '宋体'; mso-spacerun: 'yes'"> </span><span style="font-weight: normal; font-size: 14pt; font-family: '宋体'; mso-spacerun: 'yes'"><o:p></o:p></span></p> <p class="p0" style="margin-top: 0pt; margin-bottom: 0pt; text-indent: 21pt"><span style="font-weight: normal; font-size: 14pt; font-family: '宋体'; mso-spacerun: 'yes'">båQŽè‹¥X</span><span style="font-weight: normal; font-size: 14pt; vertical-align: sub; font-family: '宋体'; mso-spacerun: 'yes'">i</span><span style="font-weight: normal; font-size: 14pt; font-family: '宋体'; mso-spacerun: 'yes'"> ∈WåQŒåˆ™åˆ†åˆ«å–Y</span><span style="font-weight: normal; font-size: 14pt; vertical-align: sub; font-family: '宋体'; mso-spacerun: 'yes'">i</span><span style="font-weight: normal; font-size: 14pt; font-family: '宋体'; mso-spacerun: 'yes'"> ä¸ºX</span><span style="font-weight: normal; font-size: 14pt; vertical-align: sub; font-family: '宋体'; mso-spacerun: 'yes'">i</span><span style="font-weight: normal; font-size: 14pt; font-family: '宋体'; mso-spacerun: 'yes'">ä¸?#949;åQŒä½†æ˜¯è‹¥æ‰€æœ‰X</span><span style="font-weight: normal; font-size: 14pt; vertical-align: sub; font-family: '宋体'; mso-spacerun: 'yes'">i</span><span style="font-weight: normal; font-size: 14pt; font-family: '宋体'; mso-spacerun: 'yes'">均属于WåQŒå´ä¸èƒ½æŠŠæ‰€æœ‰Y</span><span style="font-weight: normal; font-size: 14pt; vertical-align: sub; font-family: '宋体'; mso-spacerun: 'yes'">i</span><span style="font-weight: normal; font-size: 14pt; font-family: '宋体'; mso-spacerun: 'yes'"> å–䨓εã€?nbsp;</span><span style="font-weight: normal; font-size: 14pt; font-family: '宋体'; mso-spacerun: 'yes'"><o:p></o:p></span></p> <p class="p0" style="margin-top: 0pt; margin-bottom: 0pt"><span style="font-weight: normal; font-size: 14pt; font-family: '宋体'; mso-spacerun: 'yes'">设有一文法G[S]= åQˆV</span><span style="font-weight: normal; font-size: 14pt; vertical-align: sub; font-family: '宋体'; mso-spacerun: 'yes'">N</span><span style="font-weight: normal; font-size: 14pt; font-family: '宋体'; mso-spacerun: 'yes'"> åQŒV</span><span style="font-weight: normal; font-size: 14pt; vertical-align: sub; font-family: '宋体'; mso-spacerun: 'yes'">T</span><span style="font-weight: normal; font-size: 14pt; font-family: '宋体'; mso-spacerun: 'yes'"> åQŒPåQŒSåQ‰ï¼Œå½?#949;属于该文法所描述的语­a€æ—Óž¼Œå¯æž„造文法:</span><span style="font-weight: normal; font-size: 14pt; font-family: '宋体'; mso-spacerun: 'yes'"><o:p></o:p></span></p> <p class="p0" style="margin-top: 0pt; margin-bottom: 0pt"><span style="font-weight: normal; font-size: 14pt; font-family: '宋体'; mso-spacerun: 'yes'">G1=åQˆV</span><span style="font-weight: normal; font-size: 14pt; vertical-align: sub; font-family: '宋体'; mso-spacerun: 'yes'">N1</span><span style="font-weight: normal; font-size: 14pt; font-family: '宋体'; mso-spacerun: 'yes'"> åQŒV</span><span style="font-weight: normal; font-size: 14pt; vertical-align: sub; font-family: '宋体'; mso-spacerun: 'yes'">T</span><span style="font-weight: normal; font-size: 14pt; font-family: '宋体'; mso-spacerun: 'yes'"> åQŒP</span><span style="font-weight: normal; font-size: 14pt; vertical-align: sub; font-family: '宋体'; mso-spacerun: 'yes'">1</span><span style="font-weight: normal; font-size: 14pt; font-family: '宋体'; mso-spacerun: 'yes'">åQŒS’åQ‰ï¼Œä½¿å¾—LåQˆG</span><span style="font-weight: normal; font-size: 14pt; vertical-align: sub; font-family: '宋体'; mso-spacerun: 'yes'">1</span><span style="font-weight: normal; font-size: 14pt; font-family: '宋体'; mso-spacerun: 'yes'">åQ?LåQˆGåQ‰ï¼ŒP</span><span style="font-weight: normal; font-size: 14pt; vertical-align: sub; font-family: '宋体'; mso-spacerun: 'yes'">1</span><span style="font-weight: normal; font-size: 14pt; font-family: '宋体'; mso-spacerun: 'yes'">中除S’→ε外不再含有其å®?#949;产生式,òq¶ä¸”S’不出现在ä»ÖM½•产生式的双™¾¹ã€?/span><span style="font-weight: normal; font-size: 14pt; font-family: '宋体'; mso-spacerun: 'yes'"><o:p></o:p></span></p> <p class="p0" style="margin-top: 0pt; margin-bottom: 0pt"><span style="font-weight: normal; font-size: 14pt; color: rgb(255,0,0); font-family: '宋体'; mso-spacerun: 'yes'">½Ž—法5åQ?/span><span style="font-weight: normal; font-size: 14pt; font-family: '宋体'; mso-spacerun: 'yes'"><o:p></o:p></span></p> <p class="p0" style="margin-top: 0pt; margin-bottom: 0pt"><span style="font-weight: normal; font-size: 14pt; font-family: '宋体'; mso-spacerun: 'yes'">è‹¥S不出现在ä»ÖM½•产生式的右部åQŒåˆ™å¯ç›´æŽ¥ç”¨½Ž—法2.4消除ε产生式,再加入S→εåQŒå¦åˆ™ï¼š</span><span style="font-weight: normal; font-size: 14pt; font-family: '宋体'; mso-spacerun: 'yes'"><o:p></o:p></span></p> <p class="p0" style="margin-top: 0pt; margin-bottom: 0pt"><span style="font-weight: normal; font-size: 14pt; font-family: '宋体'; mso-spacerun: 'yes'">  1åQŽå¼•入新的非¾lˆç»“½W¦S’åQ?nbsp;V</span><span style="font-weight: normal; font-size: 14pt; vertical-align: sub; font-family: '宋体'; mso-spacerun: 'yes'">N1</span><span style="font-weight: normal; font-size: 14pt; font-family: '宋体'; mso-spacerun: 'yes'">= V</span><span style="font-weight: normal; font-size: 14pt; vertical-align: sub; font-family: '宋体'; mso-spacerun: 'yes'">N</span><span style="font-weight: normal; font-size: 14pt; font-family: '宋体'; mso-spacerun: 'yes'"> ∪{ S’}</span><span style="font-weight: normal; font-size: 14pt; font-family: '宋体'; mso-spacerun: 'yes'"><o:p></o:p></span></p> <p class="p0" style="margin-top: 0pt; margin-bottom: 0pt"><span style="font-weight: normal; font-size: 14pt; font-family: '宋体'; mso-spacerun: 'yes'">  2åQŽæž„造P’ =P∪{ S’→α| S→α∈P}</span><span style="font-weight: normal; font-size: 14pt; font-family: '宋体'; mso-spacerun: 'yes'"><o:p></o:p></span></p> <p class="p0" style="margin-top: 0pt; margin-bottom: 0pt"><span style="font-weight: normal; font-size: 14pt; font-family: '宋体'; mso-spacerun: 'yes'">  3åQŽå¯¹æ–‡æ³•G1=åQˆV</span><span style="font-weight: normal; font-size: 14pt; vertical-align: sub; font-family: '宋体'; mso-spacerun: 'yes'">N</span><span style="font-weight: normal; font-size: 14pt; font-family: '宋体'; mso-spacerun: 'yes'">1 åQŒV</span><span style="font-weight: normal; font-size: 14pt; vertical-align: sub; font-family: '宋体'; mso-spacerun: 'yes'">T</span><span style="font-weight: normal; font-size: 14pt; font-family: '宋体'; mso-spacerun: 'yes'"> åQŒP</span><span style="font-weight: normal; font-size: 14pt; font-family: '宋体'; mso-spacerun: 'yes'">1</span><span style="font-weight: normal; font-size: 14pt; font-family: '宋体'; mso-spacerun: 'yes'">åQŒS’åQ‰ï¼Œæ‰§è¡Œ½Ž—法4åQŒå†åŠ å…¥S’→εã€?nbsp;</span><span style="font-weight: normal; font-size: 14pt; font-family: '宋体'; mso-spacerun: 'yes'"><o:p></o:p></span></p> <p class="p0" style="margin-top: 0pt; margin-bottom: 0pt"><span style="font-weight: normal; font-size: 14pt; font-family: '宋体'; mso-spacerun: 'yes'"><o:p></o:p></span></p> <p class="p0" style="margin-top: 0pt; margin-bottom: 0pt"><span style="font-weight: normal; font-size: 14pt; color: rgb(0,0,255); font-family: '宋体'; mso-spacerun: 'yes'">3、单产生式的消除</span><span style="font-weight: normal; font-size: 14pt; font-family: '宋体'; mso-spacerun: 'yes'"><o:p></o:p></span></p> <p class="p0" style="margin-top: 0pt; margin-bottom: 0pt"><span style="font-weight: normal; font-size: 14pt; font-family: '宋体'; mso-spacerun: 'yes'">A→BåQŒA,B∈V</span><span style="font-weight: normal; font-size: 14pt; vertical-align: sub; font-family: '宋体'; mso-spacerun: 'yes'">N</span><span style="font-weight: normal; font-size: 14pt; font-family: '宋体'; mso-spacerun: 'yes'"> æ­¤ç±»äº§ç”Ÿå¼è¢«¿UîCؓ单äñ”生式ã€?/span><span style="font-weight: normal; font-size: 14pt; font-family: '宋体'; mso-spacerun: 'yes'"><o:p></o:p></span></p> <p class="p0" style="margin-top: 0pt; margin-bottom: 0pt"><span style="font-weight: normal; font-size: 14pt; font-family: '宋体'; mso-spacerun: 'yes'">假定文法中不含有ε产生式ã€?/span><span style="font-weight: normal; font-size: 14pt; font-family: '宋体'; mso-spacerun: 'yes'"><o:p></o:p></span></p> <p class="p0" style="margin-top: 0pt; margin-bottom: 0pt"><span style="font-weight: normal; font-size: 14pt; font-family: '宋体'; mso-spacerun: 'yes'">½Ž—法6åQ?/span><span style="font-weight: normal; font-size: 14pt; font-family: '宋体'; mso-spacerun: 'yes'"><o:p></o:p></span></p> <p class="p0" style="margin-top: 0pt; margin-bottom: 0pt"><span style="font-weight: normal; font-size: 14pt; font-family: '宋体'; mso-spacerun: 'yes'">设V</span><span style="font-weight: normal; font-size: 14pt; vertical-align: sub; font-family: '宋体'; mso-spacerun: 'yes'">N</span><span style="font-weight: normal; font-size: 14pt; font-family: '宋体'; mso-spacerun: 'yes'"> ={ A</span><span style="font-weight: normal; font-size: 14pt; vertical-align: sub; font-family: '宋体'; mso-spacerun: 'yes'">1</span><span style="font-weight: normal; font-size: 14pt; font-family: '宋体'; mso-spacerun: 'yes'"> ...... A</span><span style="font-weight: normal; font-size: 14pt; vertical-align: sub; font-family: '宋体'; mso-spacerun: 'yes'">N</span><span style="font-weight: normal; font-size: 14pt; font-family: '宋体'; mso-spacerun: 'yes'"> } å¯Òޝä¸€ä¸ªA</span><span style="font-weight: normal; font-size: 14pt; vertical-align: sub; font-family: '宋体'; mso-spacerun: 'yes'">i</span><span style="font-weight: normal; font-size: 14pt; font-family: '宋体'; mso-spacerun: 'yes'"> åQ?≤i≤nåQ‰æž„造集合序åˆ?/span><span style="font-weight: normal; font-size: 14pt; font-family: '宋体'; mso-spacerun: 'yes'"><o:p></o:p></span></p> <p class="p0" style="margin-top: 0pt; margin-bottom: 0pt"><span style="font-weight: normal; font-size: 14pt; font-family: '宋体'; mso-spacerun: 'yes'">W</span><span style="font-weight: normal; font-size: 14pt; vertical-align: sub; font-family: '宋体'; mso-spacerun: 'yes'">1</span><span style="font-weight: normal; font-size: 14pt; font-family: '宋体'; mso-spacerun: 'yes'">( A</span><span style="font-weight: normal; font-size: 14pt; vertical-align: sub; font-family: '宋体'; mso-spacerun: 'yes'">i</span><span style="font-weight: normal; font-size: 14pt; font-family: '宋体'; mso-spacerun: 'yes'">åQ?{A</span><span style="font-weight: normal; font-size: 14pt; vertical-align: sub; font-family: '宋体'; mso-spacerun: 'yes'">i</span><span style="font-weight: normal; font-size: 14pt; font-family: '宋体'; mso-spacerun: 'yes'">}åQ?nbsp;</span><span style="font-weight: normal; font-size: 14pt; font-family: '宋体'; mso-spacerun: 'yes'"><o:p></o:p></span></p> <p class="p0" style="margin-top: 0pt; margin-bottom: 0pt"><span style="font-weight: normal; font-size: 14pt; font-family: '宋体'; mso-spacerun: 'yes'">W</span><span style="font-weight: normal; font-size: 14pt; vertical-align: sub; font-family: '宋体'; mso-spacerun: 'yes'">K+1</span><span style="font-weight: normal; font-size: 14pt; font-family: '宋体'; mso-spacerun: 'yes'">åQˆA</span><span style="font-weight: normal; font-size: 14pt; vertical-align: sub; font-family: '宋体'; mso-spacerun: 'yes'">i</span><span style="font-weight: normal; font-size: 14pt; font-family: '宋体'; mso-spacerun: 'yes'"> åQ? W</span><span style="font-weight: normal; font-size: 14pt; vertical-align: sub; font-family: '宋体'; mso-spacerun: 'yes'">K</span><span style="font-weight: normal; font-size: 14pt; font-family: '宋体'; mso-spacerun: 'yes'">åQˆA</span><span style="font-weight: normal; font-size: 14pt; vertical-align: sub; font-family: '宋体'; mso-spacerun: 'yes'">i</span><span style="font-weight: normal; font-size: 14pt; font-family: '宋体'; mso-spacerun: 'yes'"> åQ?#8746;{D|C→D∈PåQŒC∈W</span><span style="font-weight: normal; font-size: 14pt; vertical-align: sub; font-family: '宋体'; mso-spacerun: 'yes'">K</span><span style="font-weight: normal; font-size: 14pt; font-family: '宋体'; mso-spacerun: 'yes'">åQˆA</span><span style="font-weight: normal; font-size: 14pt; vertical-align: sub; font-family: '宋体'; mso-spacerun: 'yes'">i</span><span style="font-weight: normal; font-size: 14pt; font-family: '宋体'; mso-spacerun: 'yes'"> åQ‰ï¼ŒD∈V</span><span style="font-weight: normal; font-size: 14pt; vertical-align: sub; font-family: '宋体'; mso-spacerun: 'yes'">N</span><span style="font-weight: normal; font-size: 14pt; font-family: '宋体'; mso-spacerun: 'yes'"> }</span><span style="font-weight: normal; font-size: 14pt; font-family: '宋体'; mso-spacerun: 'yes'"><o:p></o:p></span></p> <p class="p0" style="margin-top: 0pt; margin-bottom: 0pt"><span style="font-weight: normal; font-size: 14pt; font-family: '宋体'; mso-spacerun: 'yes'">K≥1åQŒè¯¥é›†åˆåºåˆ—存在一个jåQŒæœ‰</span><span style="font-weight: normal; font-size: 14pt; font-family: '宋体'; mso-spacerun: 'yes'"><o:p></o:p></span></p> <p class="p0" style="margin-top: 0pt; margin-bottom: 0pt"><span style="font-weight: normal; font-size: 14pt; font-family: '宋体'; mso-spacerun: 'yes'">W</span><span style="font-weight: normal; font-size: 14pt; vertical-align: sub; font-family: '宋体'; mso-spacerun: 'yes'">j</span><span style="font-weight: normal; font-size: 14pt; font-family: '宋体'; mso-spacerun: 'yes'">åQˆA</span><span style="font-weight: normal; font-size: 14pt; vertical-align: sub; font-family: '宋体'; mso-spacerun: 'yes'">i</span><span style="font-weight: normal; font-size: 14pt; font-family: '宋体'; mso-spacerun: 'yes'"> åQ? W</span><span style="font-weight: normal; font-size: 14pt; vertical-align: sub; font-family: '宋体'; mso-spacerun: 'yes'">j+1</span><span style="font-weight: normal; font-size: 14pt; font-family: '宋体'; mso-spacerun: 'yes'">åQˆA</span><span style="font-weight: normal; font-size: 14pt; vertical-align: sub; font-family: '宋体'; mso-spacerun: 'yes'">i</span><span style="font-weight: normal; font-size: 14pt; font-family: '宋体'; mso-spacerun: 'yes'"> åQ?.....</span><span style="font-weight: normal; font-size: 14pt; font-family: '宋体'; mso-spacerun: 'yes'"><o:p></o:p></span></p> <p class="p0" style="margin-top: 0pt; margin-bottom: 0pt"><span style="font-weight: normal; font-size: 14pt; font-family: '宋体'; mso-spacerun: 'yes'">令WåQˆiåQ? W</span><span style="font-weight: normal; font-size: 14pt; vertical-align: sub; font-family: '宋体'; mso-spacerun: 'yes'">j</span><span style="font-weight: normal; font-size: 14pt; font-family: '宋体'; mso-spacerun: 'yes'">åQˆA</span><span style="font-weight: normal; font-size: 14pt; vertical-align: sub; font-family: '宋体'; mso-spacerun: 'yes'">i</span><span style="font-weight: normal; font-size: 14pt; font-family: '宋体'; mso-spacerun: 'yes'"> åQ?/span><span style="font-weight: normal; font-size: 14pt; font-family: '宋体'; mso-spacerun: 'yes'"><o:p></o:p></span></p> <p class="p0" style="margin-top: 0pt; margin-bottom: 0pt"><span style="font-weight: normal; font-size: 14pt; font-family: '宋体'; mso-spacerun: 'yes'">WåQˆiåQ?{B| A</span><span style="font-weight: normal; font-size: 14pt; vertical-align: sub; font-family: '宋体'; mso-spacerun: 'yes'">i</span><span style="font-weight: normal; font-size: 14pt; font-family: '宋体'; mso-spacerun: 'yes'"> =>BåQŒB∈V</span><span style="font-weight: normal; font-size: 14pt; vertical-align: sub; font-family: '宋体'; mso-spacerun: 'yes'">N</span><span style="font-weight: normal; font-size: 14pt; font-family: '宋体'; mso-spacerun: 'yes'"> }</span><span style="font-weight: normal; font-size: 14pt; font-family: '宋体'; mso-spacerun: 'yes'"><o:p></o:p></span></p> <p class="p0" style="margin-top: 0pt; margin-bottom: 0pt"><span style="font-weight: normal; font-size: 14pt; font-family: '宋体'; mso-spacerun: 'yes'">构造P’={ A</span><span style="font-weight: normal; font-size: 14pt; vertical-align: sub; font-family: '宋体'; mso-spacerun: 'yes'">i</span><span style="font-weight: normal; font-size: 14pt; font-family: '宋体'; mso-spacerun: 'yes'"> →α|B→α∈PåQŒB∈WåQˆiåQ‰ï¼Œα不是单个非终¾l“符}</span><span style="font-weight: normal; font-size: 14pt; font-family: '宋体'; mso-spacerun: 'yes'">(</span><span style="font-weight: normal; font-size: 14pt; color: rgb(0,0,255); font-family: '宋体'; mso-spacerun: 'yes'">对于A</span><span style="font-weight: normal; font-size: 14pt; vertical-align: sub; color: rgb(0,0,255); font-family: '宋体'; mso-spacerun: 'yes'">1</span><span style="font-weight: normal; font-size: 14pt; color: rgb(0,0,255); font-family: '宋体'; mso-spacerun: 'yes'">到A<sub>n</sub>çš„U操作</span><span style="font-weight: normal; font-size: 14pt; font-family: '宋体'; mso-spacerun: 'yes'">),</span><span style="font-weight: normal; font-size: 14pt; font-family: '宋体'; mso-spacerun: 'yes'">此时P′中已不含ä»ÖM½•单äñ”生式ã€?/span></p> <!--endfragment--> <img src ="http://www.aygfsteel.com/zhaochengming/aggbug/285613.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.aygfsteel.com/zhaochengming/" target="_blank">helloworld2008</a> 2009-07-06 00:45 <a href="http://www.aygfsteel.com/zhaochengming/archive/2009/07/06/285613.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>日期函数http://www.aygfsteel.com/zhaochengming/archive/2008/01/10/174346.htmlhelloworld2008helloworld2008Thu, 10 Jan 2008 08:54:00 GMThttp://www.aygfsteel.com/zhaochengming/archive/2008/01/10/174346.htmlhttp://www.aygfsteel.com/zhaochengming/comments/174346.htmlhttp://www.aygfsteel.com/zhaochengming/archive/2008/01/10/174346.html#Feedback0http://www.aygfsteel.com/zhaochengming/comments/commentRss/174346.htmlhttp://www.aygfsteel.com/zhaochengming/services/trackbacks/174346.html 1 
 2 public class ComputerWeek {
 3 
 4     /**
 5      * è®¡ç®—某一个日期是星期å‡?br />  6      * @param year òq?br />  7      * @param month æœ?br />  8      * @param day æ—?br />  9      * @return æ˜ŸæœŸ
10      */
11     public int getWeek(int year, int month, int day) {
12         // é¦–先我们知道2008-01-07是星期一
13         int weeks[] = {1,2,3,4,5,6,7};
14         int standardDay = getDaysFromAD(200817);
15         int temps = getDaysFromAD(year,month,day);
16         temps = temps - standardDay;
17         if (temps >= 0) {
18             temps %= 7;
19             return weeks[temps];
20         } else {
21             temps %=7;
22             temps += 7;
23             temps %= 7;
24             return weeks[temps];
25         }
26     }
27     
28     /**
29      * è®¡ç®—从公å…?òq?æœ?å?nbsp;到这个日期的天数
30      * @param year
31      * @param month
32      * @param day
33      * @return
34      */
35     public int getDaysFromAD(int year, int month, int day) {
36         int days = 0;
37         for (int i = 1; i < year; i++) {
38             if (isLeapYear(i)) {
39                 days += 366;
40             } else {
41                 days += 365;
42             }
43         }
44         for (int i = 1; i < month; i++) {
45             if (i == 1 || i == 3 || i == 5 || i == 7 || i == 8 || i == 10 || i == 12) {
46                 days += 31;
47             } else if (i == 2) {
48                 if (isLeapYear(year)) {
49                     days += 29;
50                 } else {
51                     days += 28;
52                 }
53             } else {
54                 days += 30;
55             }
56         }
57         days += day;
58         return days;
59     }
60     
61     /**
62      * åˆ¤æ–­æ˜¯å¦ä¸ºé—°òq?br /> 63      * @param year
64      * @return
65      */
66     public boolean isLeapYear(int year) {
67         if ((year % 4 == 0 && year % 100 != 0|| (year % 400 == 0)) {
68             return true;
69         } else {
70             return false;
71         }
72     }
73     
74     public static void main(String args[]) {
75         System.out.println(new ComputerWeek().getWeek(2008,12,31));
76     }
77 }
78 

]]>
Ö÷Õ¾Ö©Öë³ØÄ£°å£º ·ÊÏçÏØ| ÍÍÁôÏØ| ´ÈϪÊÐ| аͶû»¢ÓÒÆì| ÌïÁÖÏØ| ¼ªÁÖÊÐ| Õ¿½­ÊÐ| ÈéɽÊÐ| ¤´¨ÏØ| Áé´¨ÏØ| É£Ö²ÏØ| óÞÁ¬ÏØ| ÏɾÓÏØ| ½ÌÓý| »Æ´óÏÉÇø| Û°³ÇÏØ| Óà½­ÏØ| ½¨µÂÊÐ| »ýʯɽ| Ä®ºÓÏØ| ¤Î÷ÏØ| ÑÓ°²ÊÐ| ÎÂËÞÏØ| ÄþÃ÷ÏØ| ÄÎÂüÆì| ÐÂÖñÏØ| Æ½Ô­ÏØ| ºôÂêÏØ| °à¸êÏØ| ¸·ÐÂÊÐ| ʲÚúÊÐ| ºÍË¶ÏØ| ÕØÔ´ÏØ| Т¸ÐÊÐ| Ìì½òÊÐ| ½ú³Ç| Äþ°²ÊÐ| ³¤·áÏØ| ÖîôßÊÐ| ÒËÐËÊÐ| °ÍÑåÄ×¶ûÊÐ|