2023年4月15日集訓

2021-07-30 15:16:10 字數 2559 閱讀 4754

題目描述:

演算法實現:

#include 

#include

#define inf 1000

#define maxn 5

//儲存迷宮

int maze[maxn][maxn];

//記憶化陣列, 儲存當前結點到終點的最短路勁

int record[maxn][maxn];

//記錄還未訪問的結點, 避免結點被重複訪問

bool visit[maxn][maxn];

//方向陣列

int dir[4][2] = ;

//讀取陣列

void init()

}}//深度優先搜尋結合記憶化陣列

//當前結點的最短路徑長度 = 它的所有臨近結點最短路徑長度的最小值 +1

int search(int y, int x)

if(record[y][x] < inf && record[y][x])

//如果記錄的值不是無窮(即在以前的訪問中記錄為訪問不到的狀態)且已被

//記錄過則直接返回記錄的值

int min = inf;

for(int i = 0; i < 4; i++)

}return record[y][x] = min;

}//輸出訪問路徑

void show(int y, int x, int len)

for(int i = 0; i < 4; i++)

}}void check()

putchar('\n');

}printf("\n輸出記憶化陣列:\n");

for(int i = 0; i < maxn; i++)

putchar('\n');

}}int main()

輸出結果:

題目描述:

演算法實現:

#include 

#include

#include

#include

#define max 1000

using

namespace

std;

//位置

struct pair

};//測試案例數

int n;

//行上限與列上限

int r , c;

//儲存初始情況

char maze[max][max];

//搜尋的四個方向

int dir[4][2] = ;

//儲存火焰範圍的邊緣結點

queue

edgefires;

//儲存當前最臨近的安全結點

queue

safenodes;

//初始化陣列和佇列

void init()

if(maze[i][j] == 'f')

}//放入第乙個結點

edgefires.push(pair(fy, fx));

safenodes.push(pair(jy, jx));

}//搜尋安全路徑

void search()

//繪出火焰的擴散範圍

for(int i = edgefires.size(); i > 0; i--)

//將火焰的邊緣結點存入佇列中

if(!(maze[newy][newx] == '#'

|| maze[newy][newx] == 'f'))}}

//判定當前位置是否是出口

for(int i = safenodes.size(); i > 0; i--)

safenodes.pop();

for(int i = 0; i < 4; i++)

//在當前火焰覆蓋的範圍下向佇列中加入下乙個可走的臨近結點

if(!(maze[newy][newx] == '#'

|| maze[newy][newx] == 'f'

|| maze[newy][newx] == 'j'))}}

count++;

}}//測試函式

void show()

}putchar('\n');

}int main()

return

0;}

輸出結果:

2023年4月22日繼承

1 構造方法 構造方法的名稱和型別相同,沒有返回值型別。構造方法的主要作用就是在建立物件時執行一些初始化操作,如給成員屬性賦初始值。2 構造方法的過載 如下例中的三個構造方法,方法名相同,引數列表不同,這稱為構造方法的過載。public class penguin 構造方法的過載 public pe...

2023年2月15日實習日記

重灌了一下qemu,終於執行成功。rhel7成功載入起掛在vgpu的guest。可能是qemu的問題,也可能是 img 檔案多次重啟 之前幾乎都是強制殺死qemu程序而關機的,img可以有所損傷 不過終於載入了 vgpu。發個圖慶祝一下,哈哈,還好沒放棄。mentor說執行幀數不對,明天再看看是啥情...

2023年4月13日讀書筆記

示例來自 31天學會crm專案開發 1 md5是一種加密演算法,可將任意長度的字串轉換成乙個長度為32的字串,它是一種不可逆的加密演算法,也可以用於對比檔案md5值以此判斷檔案是否被篡改過。可以通過md5加密後的字串,進行查串,然後得到原始字串。例 create function dbo md5 s...