-
prolog 找路例子程序:
=== === === === === ===
Part 1-Adding connections
Part 2-Simple Path
example
| ?- path1(a,b,P,T).
will produce the response:
T = 15
P = [a,b] ?
Part 3 - Non-repeating path
As an example, the query:
?- path2(a,h,P,T).
will succeed and may produce the bindings:
P = [a,depot,b,d,e,f,h]
T = 155
Part 4 - Generating a path below a cost threshold
As an example, the query:
?- path_below_cost(a,[a,b,c,d,e,f,g,h],RS,300).
returns:
RS = [a,b,depot,c,d,e,g,f,h] ?
RS = [a,c,depot,b,d,e,g,f,h] ?
no
==================================
標(biāo)簽:
Part
connections
example
prolog
上傳時(shí)間:
2015-04-24
上傳用戶:ljt101007
-
數(shù)字運(yùn)算,判斷一個(gè)數(shù)是否接近素?cái)?shù)
A Niven number is a number such that the sum of its digits divides itself. For example, 111 is a Niven number because the sum of its digits is 3, which divides 111. We can also specify a number in another base b, and a number in base b is a Niven number if the sum of its digits divides its value.
Given b (2 <= b <= 10) and a number in base b, determine whether it is a Niven number or not.
Input
Each line of input contains the base b, followed by a string of digits representing a positive integer in that base. There are no leading zeroes. The input is terminated by a line consisting of 0 alone.
Output
For each case, print "yes" on a line if the given number is a Niven number, and "no" otherwise.
Sample Input
10 111
2 110
10 123
6 1000
8 2314
0
Sample Output
yes
yes
no
yes
no
標(biāo)簽:
數(shù)字
運(yùn)算
上傳時(shí)間:
2015-05-21
上傳用戶:daguda
-
電力系統(tǒng)在臺(tái)穩(wěn)定計(jì)算式電力系統(tǒng)不正常運(yùn)行方式的一種計(jì)算。它的任務(wù)是已知電力系統(tǒng)某一正常運(yùn)行狀態(tài)和受到某種擾動(dòng),計(jì)算電力系統(tǒng)所有發(fā)電機(jī)能否同步運(yùn)行
1運(yùn)行說(shuō)明:
請(qǐng)輸入初始功率S0,形如a+bi
請(qǐng)輸入無(wú)限大系統(tǒng)母線電壓V0
請(qǐng)輸入系統(tǒng)等值電抗矩陣B
矩陣B有以下元素組成的行矩陣
1正常運(yùn)行時(shí)的系統(tǒng)直軸等值電抗Xd
2故障運(yùn)行時(shí)的系統(tǒng)直軸等值電抗X d
3故障切除后的系統(tǒng)直軸等值電抗
請(qǐng)輸入慣性時(shí)間常數(shù)Tj
請(qǐng)輸入時(shí)段數(shù)N
請(qǐng)輸入哪個(gè)時(shí)段發(fā)生故障Ni
請(qǐng)輸入每時(shí)段間隔的時(shí)間dt
標(biāo)簽:
電力系統(tǒng)
正
計(jì)算
運(yùn)行
上傳時(shí)間:
2015-06-13
上傳用戶:it男一枚
-
一:需求分析
1. 問(wèn)題描述
魔王總是使用自己的一種非常精練而抽象的語(yǔ)言講話,沒(méi)人能聽(tīng)懂,但他的語(yǔ)言是可逐步解釋成人能聽(tīng)懂的語(yǔ)言,因?yàn)樗恼Z(yǔ)言是由以下兩種形式的規(guī)則由人的語(yǔ)言逐步抽象上去的:
-----------------------------------------------------------
(1) a---> (B1)(B2)....(Bm)
(2)[(op1)(p2)...(pn)]---->[o(pn)][o(p(n-1))].....[o(p1)o]
-----------------------------------------------------------
在這兩種形式中,從左到右均表示解釋.試寫一個(gè)魔王語(yǔ)言的解釋系統(tǒng),把
他的話解釋成人能聽(tīng)得懂的話.
2. 基本要求:
用下述兩條具體規(guī)則和上述規(guī)則形式(2)實(shí)現(xiàn).設(shè)大寫字母表示魔王語(yǔ)言的詞匯 小寫字母表示人的語(yǔ)言的詞匯 希臘字母表示可以用大寫字母或小寫字母代換的變量.魔王語(yǔ)言可含人的詞匯.
(1) B --> tAdA
(2) A --> sae
3. 測(cè)試數(shù)據(jù):
B(ehnxgz)B 解釋成 tsaedsaeezegexenehetsaedsae若將小寫字母與漢字建立下表所示的對(duì)應(yīng)關(guān)系,則魔王說(shuō)的話是:"天上一只鵝地上一只鵝鵝追鵝趕鵝下鵝蛋鵝恨鵝天上一只鵝地上一只鵝".
| t | d | s | a | e | z | g | x | n | h |
| 天 | 地 | 上 | 一只| 鵝 | 追 | 趕 | 下 | 蛋 | 恨 |
標(biāo)簽:
語(yǔ)言
抽象
分
上傳時(shí)間:
2014-12-02
上傳用戶:jkhjkh1982
-
The XML Toolbox converts MATLAB data types (such as double, char, struct, complex, sparse, logical) of any level of nesting to XML format and vice versa.
For example,
>> project.name = MyProject
>> project.id = 1234
>> project.param.a = 3.1415
>> project.param.b = 42
becomes with str=xml_format(project, off )
"<project>
<name>MyProject</name>
<id>1234</id>
<param>
<a>3.1415</a>
<b>42</b>
</param>
</project>"
On the other hand, if an XML string XStr is given, this can be converted easily to a MATLAB data type or structure V with the command V=xml_parse(XStr).
標(biāo)簽:
converts
Toolbox
complex
logical
上傳時(shí)間:
2016-02-12
上傳用戶:a673761058
-
電子選擇器,是利用TND-MD教學(xué)系統(tǒng)實(shí)現(xiàn)的,用來(lái)作為特定場(chǎng)合投票機(jī)器統(tǒng)計(jì)使用。所用到的芯片主要有8253定時(shí)計(jì)數(shù)器、8255A并行接口電路芯片等。使用時(shí),用戶用鍵盤輸入A,B,C,D這四個(gè)字母中的一個(gè)來(lái)作為已經(jīng)選擇的項(xiàng)目,程序?qū)⒃谄聊簧蠈?duì)應(yīng)顯示已經(jīng)選擇的“A,B,C或者D”,并且通過(guò)控制揚(yáng)聲器,發(fā)出對(duì)應(yīng)的頻率聲音信號(hào),同時(shí)相對(duì)應(yīng)的LED燈也對(duì)應(yīng)發(fā)光,以便于位于遠(yuǎn)處的計(jì)票員進(jìn)行遠(yuǎn)程計(jì)票。
標(biāo)簽:
電子
選擇器
上傳時(shí)間:
2014-10-14
上傳用戶:cc1015285075
-
將魔王的語(yǔ)言抽象為人類的語(yǔ)言:魔王語(yǔ)言由以下兩種規(guī)則由人的語(yǔ)言逐步抽象上去的:α-〉β1β2β3…βm ;θδ1δ2…-〉θδnθδn-1…θδ1
設(shè)大寫字母表示魔王的語(yǔ)言,小寫字母表示人的語(yǔ)言B-〉tAdA,A-〉sae,eg:B(ehnxgz)B解釋為tsaedsaeezegexenehetsaedsae對(duì)應(yīng)的話是:“天上一只鵝地上一只鵝鵝追鵝趕鵝下鵝蛋鵝恨鵝天上一只鵝地上一只鵝”。(t-天d-地s-上a-一只e-鵝z-追g-趕x-下n-蛋h-恨)
標(biāo)簽:
語(yǔ)言
抽象
字母
上傳時(shí)間:
2013-12-19
上傳用戶:aix008
-
【問(wèn)題描述】
在一個(gè)N*N的點(diǎn)陣中,如N=4,你現(xiàn)在站在(1,1),出口在(4,4)。你可以通過(guò)上、下、左、右四種移動(dòng)方法,在迷宮內(nèi)行走,但是同一個(gè)位置不可以訪問(wèn)兩次,亦不可以越界。表格最上面的一行加黑數(shù)字A[1..4]分別表示迷宮第I列中需要訪問(wèn)并僅可以訪問(wèn)的格子數(shù)。右邊一行加下劃線數(shù)字B[1..4]則表示迷宮第I行需要訪問(wèn)并僅可以訪問(wèn)的格子數(shù)。如圖中帶括號(hào)紅色數(shù)字就是一條符合條件的路線。
給定N,A[1..N] B[1..N]。輸出一條符合條件的路線,若無(wú)解,輸出NO ANSWER。(使用U,D,L,R分別表示上、下、左、右。)
2 2 1 2
(4,4) 1
(2,3) (3,3) (4,3) 3
(1,2) (2,2) 2
(1,1) 1
【輸入格式】
第一行是數(shù)m (n < 6 )。第二行有n個(gè)數(shù),表示a[1]..a[n]。第三行有n個(gè)數(shù),表示b[1]..b[n]。
【輸出格式】
僅有一行。若有解則輸出一條可行路線,否則輸出“NO ANSWER”。
標(biāo)簽:
點(diǎn)陣
上傳時(shí)間:
2014-06-21
上傳用戶:llandlu
-
實(shí)驗(yàn)源代碼
//Warshall.cpp #include<stdio.h> void warshall(int k,int n) { int i , j, t; int temp[20][20]; for(int a=0;a<k;a++) { printf("請(qǐng)輸入矩陣第%d 行元素:",a); for(int b=0;b<n;b++) { scanf ("%d",&temp[a][b]); } } for(i=0;i<k;i++){ for( j=0;j<k;j++){ if(temp[ j][i]==1) { for(t=0;t<n;t++) { temp[ j][t]=temp[i][t]||temp[ j][t]; } } } } printf("可傳遞閉包關(guān)系矩陣是:\n"); for(i=0;i<k;i++) { for( j=0;j<n;j++) { printf("%d", temp[i][ j]); } printf("\n"); } } void main() { printf("利用 Warshall 算法求二元關(guān)系的可傳遞閉包\n"); void warshall(int,int); int k , n; printf("請(qǐng)輸入矩陣的行數(shù) i: "); scanf("%d",&k);
四川大學(xué)實(shí)驗(yàn)報(bào)告 printf("請(qǐng)輸入矩陣的列數(shù) j: "); scanf("%d",&n); warshall(k,n); }
標(biāo)簽:
warshall
離散
實(shí)驗(yàn)
上傳時(shí)間:
2016-06-27
上傳用戶:梁雪文以
-
At present, there is a strong worldwide push toward bringing fiber closer to indi-
vidual homes and businesses. Fiber-to-the-Home/Business (FTTH/B) or close to it
networks are poised to become the next major success story for optical fiber com-
munications. In fact, FTTH connections are currently experiencing double-digit or
even higher growth rates, e.g., in the United States the annual growth rate was 112%
between September 2006 and September 2007, and their presence can add value of
U.S. $4,000–15,000 to the selling price of a home.
標(biāo)簽:
Technologies
Broadband
Networks
Access
上傳時(shí)間:
2020-05-26
上傳用戶:shancjb