上下文無關(guān)文法(Context-Free Grammar, CFG)是一個4元組G=(V, T, S, P),其中,V和T是不相交的有限集,S∈V,P是一組有限的產(chǎn)生式規(guī)則集,形如A→α,其中A∈V,且α∈(V∪T)*。V的元素稱為非終結(jié)符,T的元素稱為終結(jié)符,S是一個特殊的非終結(jié)符,稱為文法開始符。
設(shè)G=(V, T, S, P)是一個CFG,則G產(chǎn)生的語言是所有可由G產(chǎn)生的字符串組成的集合,即L(G)={x∈T* | Sx}。一個語言L是上下文無關(guān)語言(Context-Free Language, CFL),當(dāng)且僅當(dāng)存在一個CFG G,使得L=L(G)。 *⇒
例如,設(shè)文法G:S→AB
A→aA|a
B→bB|b
則L(G)={a^nb^m | n,m>=1}
其中非終結(jié)符都是大寫字母,開始符都是S,終結(jié)符都是小寫字母。
標(biāo)簽:
Context-Free
Grammar
CFG
上傳時間:
2013-12-10
上傳用戶:gaojiao1999
pstmt = conn.prepareStatement("select ordernumber,datetime,price,dayofmoney from zujie where ordernumber= "+ cdName + " ")
rs=pstmt.executeQuery()
if(rs!=null && rs.next()){
String datetime = rs.getString(2)
java.text.SimpleDateFormat formatter = new java.text.SimpleDateFormat ("yyyy-MM-dd")
Date date = new Date()
String date1=formatter.format(date)
ParsePosition pos = new ParsePosition(0)
ParsePosition pos1 = new ParsePosition(0)
Date dt1=formatter.parse(datetime,pos)
Date dt2=formatter.parse(date1,pos1)
Long l = (dt2.getTime()-dt1.getTime())/(3600*24*1000)+1
double price = rs.getDouble(3)
double dayofmoney=rs.getDouble(4)
double dayofmoneybuy=dayofmoney*l
double otherMoney = price-dayofmoneybuy
request.setAttribute("price", price)
request.setAttribute("l", l)
request.setAttribute("dayofmoney", dayofmoneybuy)
request.setAttribute("otherMoney", otherMoney)
標(biāo)簽:
prepareStatement
ordernumber
dayofmoney
datetime
上傳時間:
2013-12-14
上傳用戶:zsjinju
Instead of finding the longest common
subsequence, let us try to determine the
length of the LCS.
Then tracking back to find the LCS.
Consider a1a2…am and b1b2…bn.
Case 1: am=bn. The LCS must contain am,
we have to find the LCS of a1a2…am-1 and
b1b2…bn-1.
Case 2: am≠bn. Wehave to find the LCS of
a1a2…am-1 and b1b2…bn, and a1a2…am and
b b b
b1b2…bn-1
Let A = a1 a2 … am and B = b1 b2 … bn
Let Li j denote the length of the longest i,g g
common subsequence of a1 a2 … ai and b1 b2
… bj.
Li,j = Li-1,j-1 + 1 if ai=bj
max{ L L } a≠b i-1,j, i,j-1 if ai≠j
L0,0 = L0,j = Li,0 = 0 for 1≤i≤m, 1≤j≤n.
標(biāo)簽:
the
subsequence
determine
Instead
上傳時間:
2013-12-17
上傳用戶:evil