當前位置:首頁 » 操作系統 » 關鍵演算法

關鍵演算法

發布時間: 2022-08-23 08:04:38

⑴ VFP編程0+1+1+2+3+5+8+13+21+34+55

注意觀察這個數列的特性,每個數都是前兩個數的和,注意到這點編程應該沒有難度。
我沒有用過vfp,vfp的語法細節自己查書,關鍵演算法如下:

t1=1
t2=1
s=2
for i=1 to 4
t1=t1+t2
t2=t1+t2
s=s+t1+t2
endfor

再輸出 s即可

或者

t1=1
t2=1
s=2

do while t2<55

t1=t1+t2
t2=t1+t2
s=s+t1+t2

done

⑵ 請舉個例子說明在什麼情況下需要使用關鍵路徑演算法

關鍵路徑演算法在很多領域有應用,例如項目管理需要計算項目中各任務的關鍵路徑,對關鍵路徑上的任務需要重點跟進進度,以免影響整個項目的進度。

⑶ 數據結構演算法

鏈表-》棧-》二叉樹-》圖這樣的順序來學習這門課程
1.找c代碼,看懂,自己寫
2.有很多經典的演算法,我以前學的時候也看數據結構1800,考研用書,比較好的,把基本的數據結構這快的操作都包含進去了
3.如果你需要,在看看演算法導論。

1.是關鍵,2,3都是補充。如果只想過了這門課,上課認真聽就好了,把最最基本的鏈表,棧,樹的遞歸遍歷用c寫寫就ok了。

java關鍵字查詢演算法

import java.io.FileReader;
import java.io.BufferedReader;
import java.io.File;

public class search
{
//查找方法,參數,文件絕對路徑,查找關鍵字
public static boolean search(String filepath,String key)
{
try
{
File f = new File(filepath);
FileReader fr = new FileReader(f);
BufferedReader br = new BufferedReader(fr);
String s = "";
//int i = 1;
while((s = br.readLine()) != null)
{
if(s.indexOf(key) != -1)
{
return true;
}
}
return false;
}
catch(Exception e)
{
e.printStackTrace();
return false;
}
}
public static void main(String args[])
{
System.out.println(search.search("d://t.txt","l2"));
}
}

修改了下,加兩個變數,可以指出查找的位置。
import java.io.FileReader;
import java.io.BufferedReader;
import java.io.File;

public class search
{
//查找方法,參數,文件絕對路徑,查找關鍵字
public static String search(String filepath,String key)
{
try
{
File f = new File(filepath);
FileReader fr = new FileReader(f);
BufferedReader br = new BufferedReader(fr);
String s = "";
int i = 1;
int m = 0;
while((s = br.readLine()) != null)
{
if((m = s.indexOf(key)) != -1)
{
return "第"+i+"段,第"+m+"處";
}
i++;
}
return null;
}
catch(Exception e)
{
e.printStackTrace();
return null;
}
}
public static void main(String args[])
{
System.out.println(search.search("d://t.txt","asd"));
}
}

這個,查漢字是沒有問題的。
另外,你要全文檢索的話,indexOf()還有個方法,indexOf(int start,String key),指定開始查找的位置跟關鍵字,你查到一處後,將這個數值加1,做為繼續查找的開始位置就可以了。

⑸ 實現雞兔同籠問題的關鍵演算法

x為雞的數量,y為兔的數量。
2x+4y=m,
x+y=n。
求解:x和y?
關鍵其實就是求解二元方程的過程。

⑹ 急求JAVA五子棋關鍵演算法,關鍵問題!!

什麼演算法都不用
-------------------------------
importjava.awt.*;
importjava.awt.event.*;
importjavax.swing.*;


{
intchess[][]=newint[11][11];
booleanIs_Black_True;
mypanel()
{
Is_Black_True=true;
for(inti=0;i<11;i++)
{
for(intj=0;j<11;j++)
{
chess[i][j]=0;
}
}
addMouseListener(this);
setBackground(Color.BLUE);
setBounds(0,0,360,360);
setVisible(true);
}
publicvoidmousePressed(MouseEvente)
{
intx=e.getX();
inty=e.getY();

if(x<25||x>330+25||y<25||y>330+25)
{
return;
}
if(chess[x/30-1][y/30-1]!=0)
{
return;
}
if(Is_Black_True==true)
{
chess[x/30-1][y/30-1]=1;
Is_Black_True=false;
repaint();
Justisewiner();
return;
}
if(Is_Black_True==false)
{
chess[x/30-1][y/30-1]=2;
Is_Black_True=true;
repaint();
Justisewiner();
return;
}
}
voidDrawline(Graphicsg)
{
for(inti=30;i<=330;i+=30)
{
for(intj=30;j<=330;j+=30)
{
g.setColor(Color.WHITE);
g.drawLine(i,j,i,330);
}
}

for(intj=30;j<=330;j+=30)
{
g.setColor(Color.WHITE);
g.drawLine(30,j,330,j);
}

}
voidDrawchess(Graphicsg)
{
for(inti=0;i<11;i++)
{
for(intj=0;j<11;j++)
{
if(chess[i][j]==1)
{
g.setColor(Color.BLACK);
g.fillOval((i+1)*30-8,(j+1)*30-8,16,16);
}
if(chess[i][j]==2)
{
g.setColor(Color.WHITE);
g.fillOval((i+1)*30-8,(j+1)*30-8,16,16);
}
}
}
}
voidJustisewiner()
{
intblack_count=0;
intwhite_count=0;
inti=0;

for(i=0;i<11;i++)//橫向判斷
{
for(intj=0;j<11;j++)
{
if(chess[i][j]==1)
{
black_count++;
if(black_count==5)
{
JOptionPane.showMessageDialog(this,"黑棋勝利");
Clear_Chess();
return;
}
}
else
{
black_count=0;
}
if(chess[i][j]==2)
{
white_count++;
if(white_count==5)
{
JOptionPane.showMessageDialog(this,"白棋勝利");
Clear_Chess();
return;
}
}
else
{
white_count=0;
}
}
}

for(i=0;i<11;i++)//豎向判斷
{
for(intj=0;j<11;j++)
{
if(chess[j][i]==1)
{
black_count++;
if(black_count==5)
{
JOptionPane.showMessageDialog(this,"黑棋勝利");
Clear_Chess();
return;
}
}
else
{
black_count=0;
}
if(chess[j][i]==2)
{
white_count++;
if(white_count==5)
{
JOptionPane.showMessageDialog(this,"白棋勝利");
Clear_Chess();
return;
}
}
else
{
white_count=0;
}
}
}

for(i=0;i<7;i++)//左向右斜判斷
{
for(intj=0;j<7;j++)
{
for(intk=0;k<5;k++)
{
if(chess[i+k][j+k]==1)
{
black_count++;
if(black_count==5)
{
JOptionPane.showMessageDialog(this,"黑棋勝利");
Clear_Chess();
return;
}
}
else
{
black_count=0;
}
if(chess[i+k][j+k]==2)
{
white_count++;
if(white_count==5)
{
JOptionPane.showMessageDialog(this,"白棋勝利");
Clear_Chess();
return;
}
}
else
{
white_count=0;
}
}
}
}

for(i=4;i<11;i++)//右向左斜判斷
{
for(intj=6;j>=0;j--)
{
for(intk=0;k<5;k++)
{
if(chess[i-k][j+k]==1)
{
black_count++;
if(black_count==5)
{
JOptionPane.showMessageDialog(this,"黑棋勝利");
Clear_Chess();
return;
}
}
else
{
black_count=0;
}
if(chess[i-k][j+k]==2)
{
white_count++;
if(white_count==5)
{
JOptionPane.showMessageDialog(this,"白棋勝利");
Clear_Chess();
return;
}
}
else
{
white_count=0;
}
}
}
}

}
voidClear_Chess()
{
for(inti=0;i<11;i++)
{
for(intj=0;j<11;j++)
{
chess[i][j]=0;
}
}
repaint();
}
publicvoidpaint(Graphicsg)
{
Drawline(g);
Drawchess(g);
}
publicvoidmouseExited(MouseEvente){}
publicvoidmouseEntered(MouseEvente){}
publicvoidmouseReleased(MouseEvente){}
publicvoidmouseClicked(MouseEvente){}

}


{
mypanelpanel;
myframe()
{
setLayout(null);
panel=newmypanel();
add(panel);
panel.setBounds(0,23,360,360);
setTitle("單人版五子棋");
setBounds(200,200,360,383);
setVisible(true);
addWindowListener(this);

}
publicvoidwindowClosing(WindowEvente)
{
System.exit(0);
}
publicvoidwindowDeactivated(WindowEvente){}
publicvoidwindowActivated(WindowEvente){}
publicvoidwindowOpened(WindowEvente){}
publicvoidwindowClosed(WindowEvente){}
publicvoidwindowIconified(WindowEvente){}
publicvoidwindowDeiconified(WindowEvente){}
}
publicclassmywindow
{
publicstaticvoidmain(Stringargc[])
{
myframef=newmyframe();
}
}

⑺ 中國古代數學優秀演算法,除輾轉相除法秦九韶演算法和更相減損術外

「方程術」的關鍵演算法叫「遍乘直除」,《九章算術》卷4中有「開方術」和「開立方術」 「四元術」 「中國剩餘定理」
中國古代數學將幾何問題也歸結為代數方程,然後用程式化的演算法來求解。因此,中國古代數學具有明顯的演算法化、機械化的特徵。以下擇要舉例說明中國古代數學發展的這種特徵。

⑻ C語言 超市信息管理程序 關鍵演算法是什麼

應該是查找貨品和增加貨品 這兩種演算法吧 你要計算怎麼查找該貨品 速度最快 比如你賣一個貨品的貨號編號是c0001234 那麼你就要查找這個貨品 並輸出這個貨品的單價 反之 增加貨品 你就要設計怎麼存儲該貨品的信息 才是最好的 我想應該就這兩個

⑼ 關鍵線路確定的演算法步驟是怎樣的

第1步,拓撲排序,確定頂點的先後次序
第2步,按頂點先後順序從前向後遞推,求出結點的最早開工時間
第3步,從後向前倒推,求出結點的最遲允許開工時間
第4步,計算各弧邊(也就是活動)的最早和最遲開工時間
第5步,計算活動的鬆弛時間,為0的就是關鍵活動,從始點到終點的所有關鍵活動就是關鍵路徑

熱點內容
跳轉頁源碼 發布:2024-09-17 03:13:05 瀏覽:542
html文件上傳表單 發布:2024-09-17 03:08:02 瀏覽:783
聊天軟體編程 發布:2024-09-17 03:00:07 瀏覽:725
linuxoracle安裝路徑 發布:2024-09-17 01:57:29 瀏覽:688
兩個安卓手機照片怎麼同步 發布:2024-09-17 01:51:53 瀏覽:207
cf編譯後沒有黑框跳出來 發布:2024-09-17 01:46:54 瀏覽:249
安卓怎麼禁用應用讀取列表 發布:2024-09-17 01:46:45 瀏覽:524
win10設密碼在哪裡 發布:2024-09-17 01:33:32 瀏覽:662
情逢敵手迅雷下載ftp 發布:2024-09-17 01:32:35 瀏覽:337
安卓如何讓軟體按照步驟自動運行 發布:2024-09-17 01:28:27 瀏覽:197