主頁 > 前端設計 > 圖論-單源最短路徑(Dijskal演算法)

圖論-單源最短路徑(Dijskal演算法)

2020-10-12 15:40:22 前端設計

文章目錄

  • Dijkstra
  • 原理
  • 模板
  • 例題
    • HDU-2544 最短路
    • HDU-2680 Choose the best route
    • POJ-1062 昂貴的聘禮
    • POJ-1511 Invitation Cards

Dijkstra


Dijkstra演算法是圖論中用來求單源最短路徑的經典演算法,復雜度可以優化到 O ( m l o g ( n ) ) O(mlog(n)) O(mlog(n)),從整體上看就是從一個起點,擴散到整個圖的程序,
打個比方,把圖的邊看成多米諾骨牌,骨牌數量和邊的權值成正比,假設骨牌倒下速度一樣,從起點推倒骨牌,所連邊上的骨牌都倒下,到達所有能到達的終點,并且某個結點先倒下來的骨牌就是最短路徑,后倒過來的骨牌對最短路徑沒有貢獻,忽略之,

原理


Dijkstra演算法應用了貪心的思想,即“抄近路走”,維護兩個集合 A A A B B B A A A表示已確定最短路徑的結點集(紅色表示), B B B表示鄰居結點(藍色表示),
在這里插入圖片描述

  1. 首先把起點1放入 A A A中,把它的所有鄰居放入 B B B
    在這里插入圖片描述

  2. B B B中找距離起點最短的結點放入 A A A中,即結點3,并把它的鄰居加入進 B B B,距離是起點到該節點的距離+該節點到鄰居的距離,
    在這里插入圖片描述

  3. 此時 B B B中存在相同結點2,我們取距離更短的那個,即舍棄(2,5)
    在這里插入圖片描述

  4. 以此類推,把 B B B中距離最短的結點2放入 A A A中,加入鄰居,然后舍棄更遠的(4,7)
    在這里插入圖片描述

  5. 最后得到起點到其他結點的最短路徑
    在這里插入圖片描述
    上述方法中,對于每次尋找 B B B中距離最近結點,可以用優先佇列實作,這樣依賴復雜度就能優化到 O ( m l o g ( n ) ) O(mlog(n)) O(mlog(n))
    如果要列印路徑,定義一個陣列 p r e [ ] pre[] pre[]記錄前驅結點就好了,也就是它是作為誰的鄰居進入 B B B中的,然后遞回列印,

模板


struct edge {  //邊
	int from, to, w;  //起點,終點,權值
	edge(int a, int b, int c) {
		from = a, to = b, w = c;
	}
};
struct node {
	int id, dis; //即圖解中的(結點,距離)
	node(int a, int b) {
		id = a, dis = b;
	}
	bool operator< (const node &a)const {
		return a.dis < dis;
	}
};
int n, m, x, y, z;
vector<edge>e[maxn];  //鄰接表存圖
int dis[maxn], pre[maxn]; //記錄最短路徑和 前驅節點
bool vis[maxn];  //記錄是否已入A,實作舍棄操作
void print_path(int s, int t) { //列印起點s到點t最短路徑
	if (s == t)return;
	print_path(s, pre[t]);
	printf("%d ", t);
}
void dijkstra(int s) { //傳入起點
	memset(dis, inf, sizeof(dis));
	memset(vis, false, sizeof(vis));
	dis[s] = 0;
	priority_queue<node>q;  //優先佇列
	q.push(node(s, dis[s]));  //入隊起點
	while (!q.empty()) {
		node cur = q.top();
		q.pop();
		if (vis[cur.id])continue;
		vis[cur.id] = true;  //即已找到最短路徑
		for (int i = 0; i < e[cur.id].size(); i++) {  //檢查所有鄰居
			edge nex = e[cur.id][i];
			if (vis[nex.to])continue;  //舍棄(更優的已經get)
			if (dis[nex.to] > nex.w + cur.dis) { //擴展新鄰居
				dis[nex.to] = nex.w + cur.dis;
				q.push(node(nex.to, dis[nex.to]));
				//pre[nex.to] = cur.id;  //記錄路徑
			}
		}
	}
}

例題


HDU-2544 最短路

HDU-2544 最短路

Problem Description
在每年的校賽里,所有進入決賽的同學都會獲得一件很漂亮的t-shirt,但是每當我們的作業人員把上百件的衣服從商店運回到賽場的時候,卻是非常累的!所以現在他們想要尋找最短的從商店到賽場的路線,你可以幫助他們嗎?
Input
輸入包括多組資料,每組資料第一行是兩個整數N、M(N<=100,M<=10000),N表示成都的大街上有幾個路口,標號為1的路口是商店所在地,標號為N的路口是賽場所在地,M則表示在成都有幾條路,N=M=0表示輸入結束,接下來M行,每行包括3個整數A,B,C(1<=A,B<=N,1<=C<=1000),表示在路口A與路口B之間有一條路,我們的作業人員需要C分鐘的時間走過這條路,
輸入保證至少存在1條商店到賽場的路線,
Output
對于每組輸入,輸出一行,表示作業人員從商店走到賽場的最短時間
Sample Input
2 1
1 2 3
3 3
1 2 5
2 3 5
3 1 2
0 0
Sample Output
3
2

分析:模板題

#include<bits/stdc++.h>
using namespace std;
#define inf 0x3f3f3f3f
const int maxn = 102;
struct edge { 
	int from, to, w;
	edge(int a, int b, int c) {
		from = a, to = b, w = c;
	}
};
struct node {
	int id, dis;
	node(int a, int b) {
		id = a, dis = b;
	}
	bool operator< (const node &a)const {
		return a.dis < dis;
	}
};
int n, m, x, y, z;
vector<edge>e[maxn];  
int dis[maxn];
bool vis[maxn];  
void dijkstra(int s) {
	dis[s] = 0;
	priority_queue<node>q; 
	q.push(node(s, dis[s])); 
	while (!q.empty()) {
		node cur = q.top();
		q.pop();
		if (vis[cur.id])continue;
		vis[cur.id] = true; 
		for (int i = 0; i < e[cur.id].size(); i++) {  
			edge nex = e[cur.id][i];
			if (vis[nex.to])continue;  
			if (dis[nex.to] > nex.w + cur.dis) {
				dis[nex.to] = nex.w + cur.dis;
				q.push(node(nex.to, dis[nex.to]));
			}
		}
	}
}
int main() {
	while (~scanf("%d%d", &n, &m)) {
		if (n == 0 && m == 0)break;
		for (int i = 1; i <= n; i++)e[i].clear();
		memset(dis, inf, sizeof(dis));
		memset(vis, false, sizeof(vis));
		while (m--) {
			scanf("%d%d%d", &x, &y, &z);
			e[x].push_back(edge(x, y, z));
			e[y].push_back(edge(y, x, z));
		}
		dijkstra(1);
		printf("%d\n", dis[n]);
	}
	return 0;
}

HDU-2680 Choose the best route

HDU-2680 Choose the best route

Problem Description
One day , Kiki wants to visit one of her friends. As she is liable to carsickness , she wants to arrive at her friend’s home as soon as possible . Now give you a map of the city’s traffic route, and the stations which are near Kiki’s home so that she can take. You may suppose Kiki can change the bus at any station. Please find out the least time Kiki needs to spend. To make it easy, if the city have n bus stations ,the stations will been expressed as an integer 1,2,3…n.
Input
There are several test cases.
Each case begins with three integers n, m and s,(n<1000,m<20000,1=<s<=n) n stands for the number of bus stations in this city and m stands for the number of directed ways between bus stations .(Maybe there are several ways between two bus stations .) s stands for the bus station that near Kiki’s friend’s home.
Then follow m lines ,each line contains three integers p , q , t (0<t<=1000). means from station p to station q there is a way and it will costs t minutes .
Then a line with an integer w(0<w<n), means the number of stations Kiki can take at the beginning. Then follows w integers stands for these stations.
Output
The output contains one line for each data set : the least time Kiki needs to spend ,if it’s impossible to find such a route ,just output “-1”.
Sample Input
5 8 5
1 2 2
1 5 3
1 3 4
2 4 7
2 5 6
2 3 5
3 5 1
4 5 1
2
2 3
4 3 4
1 2 3
1 3 4
2 3 2
1
1
Sample Output
1
-1

分析
站臺編號1~n,假設起點是0(超級源點),那么可以直接出發的點置距離為0,然后套演算法即可,

#include<bits/stdc++.h>
using namespace std;
#define inf 0x3f3f3f3f
const int maxn = 1003;
struct node {
	int id, dis;
	node(int a, int b) {
		id = a, dis = b;
	}
	bool operator <(const node& a)const {
		return a.dis < dis;
	}
};
int mp[maxn][maxn], dis[maxn];
bool vis[maxn];
int n, m, e, x, y, z;
void dijkstra() {
	dis[0] = 0;
	priority_queue<node>q;
	q.push(node(0, dis[0]));
	while (!q.empty()) {
		node cur = q.top();
		q.pop();
		if (vis[cur.id])continue;
		vis[cur.id] = true;
		for (int i = 0; i <= n; i++) {
			if (mp[cur.id][i] == inf)continue; //無路
			if (vis[i])continue;
			if (dis[i] > mp[cur.id][i] + cur.dis) {
				dis[i] = mp[cur.id][i] + cur.dis;
				q.push(node(i, dis[i]));
			}
		}
	}
}
int main() {
	while (~scanf("%d%d%d", &n, &m, &e)) {
		memset(mp, inf, sizeof(mp));
		memset(dis, inf, sizeof(dis));
		memset(vis, false, sizeof(vis));
		while (m--) {
			scanf("%d%d%d", &x, &y, &z);
			if (z < mp[x][y])  //重邊
				mp[x][y] = z;
		}
		scanf("%d", &x);
		while (x--) { //置距起點為0
			scanf("%d", &y);
			mp[0][y] = 0;
		}
		dijkstra();
		if (dis[e] == inf)puts("-1");
		else printf("%d\n", dis[e]);
	}
	return 0;
}

插播反爬資訊 )博主CSDN地址:https://wzlodq.blog.csdn.net

POJ-1062 昂貴的聘禮

POJ-1062 昂貴的聘禮

Problem Description
年輕的探險家來到了一個印第安部落里,在那里他和酋長的女兒相愛了,于是便向酋長去求親,酋長要他用10000個金幣作為聘禮才答應把女兒嫁給他,探險家拿不出這么多金幣,便請求酋長降低要求,酋長說:“嗯,如果你能夠替我弄到大祭司的皮襖,我可以只要8000金幣,如果你能夠弄來他的水晶球,那么只要5000金幣就行了,“探險家就跑到大祭司那里,向他要求皮襖或水晶球,大祭司要他用金幣來換,或者替他弄來其他的東西,他可以降低價格,探險家于是又跑到其他地方,其他人也提出了類似的要求,或者直接用金幣換,或者找到其他東西就可以降低價格,不過探險家沒必要用多樣東西去換一樣東西,因為不會得到更低的價格,探險家現在很需要你的幫忙,讓他用最少的金幣娶到自己的心上人,另外他要告訴你的是,在這個部落里,等級觀念十分森嚴,地位差距超過一定限制的兩個人之間不會進行任何形式的直接接觸,包括交易,他是一個外來人,所以可以不受這些限制,但是如果他和某個地位較低的人進行了交易,地位較高的的人不會再和他交易,他們認為這樣等于是間接接觸,反過來也一樣,因此你需要在考慮所有的情況以后給他提供一個最好的方案,
為了方便起見,我們把所有的物品從1開始進行編號,酋長的允諾也看作一個物品,并且編號總是1,每個物品都有對應的價格P,主人的地位等級L,以及一系列的替代品Ti和該替代品所對應的"優惠"Vi,如果兩人地位等級差距超過了M,就不能"間接交易”,你必須根據這些資料來計算出探險家最少需要多少金幣才能娶到酋長的女兒,
Input
輸入第一行是兩個整數M,N(1 <= N <= 100),依次表示地位等級差距限制和物品的總數,接下來按照編號從小到大依次給出了N個物品的描述,每個物品的描述開頭是三個非負整數P、L、X(X < N),依次表示該物品的價格、主人的地位等級和替代品總數,接下來X行每行包括兩個整數T和V,分別表示替代品的編號和"優惠價格”,
Output
輸出最少需要的金幣數,
Sample Input
1 4
10000 3 2
2 8000
3 5000
1000 2 1
4 200
3000 2 1
4 200
50 2 0
Sample Output
5250

分析
把物品看作圖上的結點,互換關系看作邊,求最小花費也就是從起點到某一點的最短路徑,不過還需處理等級限制,只需要列舉等級區間,每次對滿足區間的點做dijkstra()即可,
比如起點等級是5,限制是3,那么列舉的區間有[2,5]、[3,6]、[4,7]、[5,8]詳見代碼,

#include<cstdio>
#include<queue>
#include<cstring>
#include<algorithm>
using namespace std;
#define inf 0x3f3f3f3f
const int maxn = 102;
struct node {
	int id, dis;
	node(int a, int b) {
		id = a, dis = b;
	}
	bool operator<(const node& a)const {
		return a.dis < dis;
	}
};
int n, m, x, y, z;
int mp[maxn][maxn], dis[maxn];
int lev[maxn], val[maxn];
bool tag[maxn], vis[maxn];
int dijkstra() {
	memset(vis, false, sizeof(vis));
	memset(dis, inf, sizeof(dis));
	priority_queue<node>q;
	dis[1] = 0;
	q.push(node(1, dis[1]));
	while (!q.empty()) {
		node cur = q.top();
		q.pop();
		if (vis[cur.id])continue;
		vis[cur.id] = true;
		for (int i = 1; i <= n; i++) {
			if (vis[i] || !tag[i])continue; //多一個判斷:是否在列舉區間內
			if (dis[i] > mp[cur.id][i] + cur.dis) {
				dis[i] = mp[cur.id][i] + cur.dis;
				q.push(node(i, dis[i]));
			}
		}
	}
	int rtn = inf;
	for (int i = 1; i <= n; i++) 
		if (rtn > dis[i] + val[i])  //記得加上結點權值
			rtn = dis[i] + val[i];
	return rtn;
}
int main() {
	scanf("%d%d", &m, &n);
	memset(mp, inf, sizeof(mp));
	for (int i = 1; i <= n; i++) {
		scanf("%d%d%d", &val[i], &lev[i], &x);
		while (x--) {
			scanf("%d%d", &y, &z);
			mp[i][y] = z;
		}
	}
	int ans = inf;
	for (int i = 0; i <= m; i++) {
		memset(tag, false, sizeof(tag));
		for (int j = 1; j <= n; j++) {  //列舉
			if (lev[1] - m + i <= lev[j] && lev[1] + i >= lev[j])
				tag[j] = true;
		}
		ans = min(ans, dijkstra());
	}
	printf("%d\n", ans);
	return 0;
}

POJ-1511 Invitation Cards

POJ-1511 Invitation Cards

Problem Description
In the age of television, not many people attend theater performances. Antique Comedians of Malidinesia are aware of this fact. They want to propagate theater and, most of all, Antique Comedies. They have printed invitation cards with all the necessary information and with the programme. A lot of students were hired to distribute these invitations among the people. Each student volunteer has assigned exactly one bus stop and he or she stays there the whole day and gives invitation to people travelling by bus. A special course was taken where students learned how to influence people and what is the difference between influencing and robbery.
The transport system is very special: all lines are unidirectional and connect exactly two stops. Buses leave the originating stop with passangers each half an hour. After reaching the destination stop they return empty to the originating stop, where they wait until the next full half an hour, e.g. X:00 or X:30, where ‘X’ denotes the hour. The fee for transport between two stops is given by special tables and is payable on the spot. The lines are planned in such a way, that each round trip (i.e. a journey starting and finishing at the same stop) passes through a Central Checkpoint Stop (CCS) where each passenger has to pass a thorough check including body scan.
All the ACM student members leave the CCS each morning. Each volunteer is to move to one predetermined stop to invite passengers. There are as many volunteers as stops. At the end of the day, all students travel back to CCS. You are to write a computer program that helps ACM to minimize the amount of money to pay every day for the transport of their employees.
Input
The input consists of N cases. The first line of the input contains only positive integer N. Then follow the cases. Each case begins with a line containing exactly two integers P and Q, 1 <= P,Q <= 1000000. P is the number of stops including CCS and Q the number of bus lines. Then there are Q lines, each describing one bus line. Each of the lines contains exactly three numbers - the originating stop, the destination stop and the price. The CCS is designated by number 1. Prices are positive integers the sum of which is smaller than 1000000000. You can also assume it is always possible to get from any stop to any other stop.
Output
For each case, print one line containing the minimum amount of money to be paid each day by ACM for the travel costs of its volunteers.
Sample Input
2
2 2
1 2 13
2 1 33
4 6
1 2 10
2 1 60
1 3 20
3 4 10
2 4 5
4 1 50
Sample Output
46
210

分析
n站點m條公交路線,只從起點到終點(單向),求往返最小花費,來回往返兩次,把來的單向路弄一次,再把路反過來弄一次就行了,
注意資料較大用鄰接矩陣和long long,

#include<cstdio>
#include<cstring>
#include<queue>
using namespace std;
#define inf 0x3f3f3f3f
typedef long long ll;
const int maxn = 1000006;
struct node {
	int id, dis;
	node(int a, int b) {
		id = a, dis = b;
	}
	bool operator<(const node& a)const {
		return a.dis < dis;
	}
};
struct edge {
	int from, to, w;
	edge(int a, int b, int c) {
		from = a, to = b, w = c;
	}
};
vector<edge>e[maxn];
int t, n, m;
int dis[maxn];
int from[maxn], to[maxn], cost[maxn];
bool vis[maxn];
void dijkstra(int s) {
	memset(dis, inf, sizeof(dis));
	memset(vis, false, sizeof(vis));
	dis[s] = 0;
	priority_queue<node>q;
	q.push(node(s, dis[s]));
	while (!q.empty()) {
		node cur = q.top();
		q.pop();
		if (vis[cur.id])continue;
		vis[cur.id] = true;
		for (int i = 0; i < e[cur.id].size(); i++) {
			edge nex = e[cur.id][i];
			if (vis[nex.to])continue;
			if (dis[nex.to] > cur.dis + nex.w) {
				dis[nex.to] = cur.dis + nex.w;
				q.push(node(nex.to, dis[nex.to]));
			}
		}
	}
}
int main() {
	scanf("%d", &t);
	while (t--) {
		scanf("%d%d", &n, &m);
		for (int i = 0; i <= n; i++)e[i].clear();
		for (int i = 0; i < m; i++) {
			scanf("%d%d%d", &from[i], &to[i], &cost[i]);
			e[from[i]].push_back(edge(from[i], to[i], cost[i]));
		}
		dijkstra(1);
		ll ans = 0;
		for (int i = 1; i <= n; i++)
			ans += dis[i];
		for (int i = 0; i <= n; i++)e[i].clear();
		for (int i = 0; i < m; i++) //反轉路的方向
			e[to[i]].push_back(edge(to[i], from[i], cost[i]));
		dijkstra(1);
		for (int i = 1; i <= n; i++)
			ans += dis[i];
		printf("%lld\n", ans);
	}
	return 0;
}

原創不易,請勿轉載本不富裕的訪問量雪上加霜
博主首頁:https://wzlodq.blog.csdn.net
如果文章對你有幫助,記得一鍵三連?

轉載請註明出處,本文鏈接:https://www.uj5u.com/qianduan/169128.html

標籤:其他

上一篇:基于TensorFlow Object Detection API 實作利用雙層模型進行(人體識別+其他)安全帽與口罩的檢測與判定

下一篇:Python GUI編程(Tkinter)、tk模塊使用教程、視窗化創建、視窗怎么排版,對應位置放對應東西。

標籤雲
其他(157675) Python(38076) JavaScript(25376) Java(17977) C(15215) 區塊鏈(8255) C#(7972) AI(7469) 爪哇(7425) MySQL(7132) html(6777) 基礎類(6313) sql(6102) 熊猫(6058) PHP(5869) 数组(5741) R(5409) Linux(5327) 反应(5209) 腳本語言(PerlPython)(5129) 非技術區(4971) Android(4554) 数据框(4311) css(4259) 节点.js(4032) C語言(3288) json(3245) 列表(3129) 扑(3119) C++語言(3117) 安卓(2998) 打字稿(2995) VBA(2789) Java相關(2746) 疑難問題(2699) 细绳(2522) 單片機工控(2479) iOS(2429) ASP.NET(2402) MongoDB(2323) 麻木的(2285) 正则表达式(2254) 字典(2211) 循环(2198) 迅速(2185) 擅长(2169) 镖(2155) 功能(1967) .NET技术(1958) Web開發(1951) python-3.x(1918) HtmlCss(1915) 弹簧靴(1913) C++(1909) xml(1889) PostgreSQL(1872) .NETCore(1853) 谷歌表格(1846) Unity3D(1843) for循环(1842)

熱門瀏覽
  • vue移動端上拉加載

    可能做得過于簡單或者比較low,請各位大佬留情,一起探討技術 ......

    uj5u.com 2020-09-10 04:38:07 more
  • 優美網站首頁,頂部多層導航

    一個個人用的瀏覽器首頁,可以把一下常用的網站放在這里,平常打開會比較方便。 第一步,HTML代碼 <script src=https://www.cnblogs.com/szharf/p/"js/jquery-3.4.1.min.js"></script> <div id="navigate"> <ul> <li class="labels labels_1"> ......

    uj5u.com 2020-09-10 04:38:47 more
  • 頁面為要加<!DOCTYPE html>

    最近因為寫一個js函式,需要用到$(window).height(); 由于手寫demo的時候,過于自信,其實對前端方面的認識也不夠體系,用文本檔案直接敲出來的html代碼,第一行沒有加上<!DOCTYPE html> 導致了$(window).height();的結果直接是整個document的高 ......

    uj5u.com 2020-09-10 04:38:52 more
  • WordPress網站程式手動升級要做好資料備份

    WordPress博客網站程式在進行升級前,必須要做好網站資料的備份,這個問題良家佐言是遇見過的;在剛開始接觸WordPress博客程式的時候,因為升級問題和博客網站的修改的一些嘗試,良家佐言是吃盡了苦頭。因為購買的是西部數碼的空間和域名,每當佐言把自己的WordPress博客網站搞到一塌糊涂的時候 ......

    uj5u.com 2020-09-10 04:39:30 more
  • WordPress程式不能升級為5.4.2版本的原因

    WordPress是一款個人博客系統,受到英文博客愛好者和中文博客愛好者的追捧,并逐步演化成一款內容管理系統軟體;它是使用PHP語言和MySQL資料庫開發的,用戶可以在支持PHP和MySQL資料庫的服務器上使用自己的博客。每一次WordPress程式的更新,就會牽動無數WordPress愛好者的心, ......

    uj5u.com 2020-09-10 04:39:49 more
  • 使用CSS3的偽元素進行首字母下沉和首行改變樣式

    網頁中常見的一種效果,首字改變樣式或者首行改變樣式,效果如下圖。 代碼: <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, ......

    uj5u.com 2020-09-10 04:40:09 more
  • 關于a標簽的講解

    什么是a標簽? <a> 標簽定義超鏈接,用于從一個頁面鏈接到另一個頁面。 <a> 元素最重要的屬性是 href 屬性,它指定鏈接的目標。 a標簽的語法格式:<a href=https://www.cnblogs.com/summerxbc/p/"指定要跳轉的目標界面的鏈接">需要展示給用戶看見的內容</a> a標簽 在所有瀏覽器中,鏈接的默認外觀如下: 未被訪問的鏈接帶 ......

    uj5u.com 2020-09-10 04:40:11 more
  • 前端輪播圖

    在需要輪播的頁面是引入swiper.min.js和swiper.min.css swiper.min.js地址: 鏈接:https://pan.baidu.com/s/15Uh516YHa4CV3X-RyjEIWw 提取碼:4aks swiper.min.css地址 鏈接:https://pan.b ......

    uj5u.com 2020-09-10 04:40:13 more
  • 如何設定html中的背景圖片(全屏顯示,且不拉伸)

    1 <style>2 body{background-image:url(https://uploadbeta.com/api/pictures/random/?key=BingEverydayWallpaperPicture); 3 background-size:cover;background ......

    uj5u.com 2020-09-10 04:40:16 more
  • Java學習——HTML詳解(上)

    HTML詳解 初識HTML Hyper Text Markup Language(超文本標記語言) 1 <!--DOCTYPE:告訴瀏覽器我們要使用什么規范--> 2 <!DOCTYPE html> 3 <html lang="en"> 4 <head> 5 <!--meta 描述性的標簽,描述一些 ......

    uj5u.com 2020-09-10 04:40:33 more
最新发布
  • 我的第一個NPM包:panghu-planebattle-esm(胖虎飛機大戰)使用說明

    好家伙,我的包終于開發完啦 歡迎使用胖虎的飛機大戰包!! 為你的主頁添加色彩 這是一個有趣的網頁小游戲包,使用canvas和js開發 使用ES6模塊化開發 效果圖如下: (覺得圖片太sb的可以自己改) 代碼已開源!! Git: https://gitee.com/tang-and-han-dynas ......

    uj5u.com 2023-04-20 07:59:23 more
  • 生產事故-走近科學之消失的JWT

    入職多年,面對生產環境,盡管都是小心翼翼,慎之又慎,還是難免捅出簍子。輕則滿頭大汗,面紅耳赤。重則系統停擺,損失資金。每一個生產事故的背后,都是寶貴的經驗和教訓,都是專案成員的血淚史。為了更好地防范和遏制今后的各類事故,特開此專題,長期更新和記錄大大小小的各類事故。有些是親身經歷,有些是經人耳傳口授 ......

    uj5u.com 2023-04-18 07:55:04 more
  • 記錄--Canvas實作打飛字游戲

    這里給大家分享我在網上總結出來的一些知識,希望對大家有所幫助 打開游戲界面,看到一個畫面簡潔、卻又富有挑戰性的游戲。螢屏上,有一個白色的矩形框,里面不斷下落著各種單詞,而我需要迅速地輸入這些單詞。如果我輸入的單詞與螢屏上的單詞匹配,那么我就可以獲得得分;如果我輸入的單詞錯誤或者時間過長,那么我就會輸 ......

    uj5u.com 2023-04-04 08:35:30 more
  • 了解 HTTP 看這一篇就夠

    在學習網路之前,了解它的歷史能夠幫助我們明白為何它會發展為如今這個樣子,引發探究網路的興趣。下面的這張圖片就展示了“互聯網”誕生至今的發展歷程。 ......

    uj5u.com 2023-03-16 11:00:15 more
  • 藍牙-低功耗中心設備

    //11.開啟藍牙配接器 openBluetoothAdapter //21.開始搜索藍牙設備 startBluetoothDevicesDiscovery //31.開啟監聽搜索藍牙設備 onBluetoothDeviceFound //30.停止監聽搜索藍牙設備 offBluetoothDevi ......

    uj5u.com 2023-03-15 09:06:45 more
  • canvas畫板(滑鼠和觸摸)

    <!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>canves</title> <style> #canvas { cursor:url(../images/pen.png),crosshair; } #canvasdiv{ bo ......

    uj5u.com 2023-02-15 08:56:31 more
  • 手機端H5 實作自定義拍照界面

    手機端 H5 實作自定義拍照界面也可以使用 MediaDevices API 和 <video> 標簽來實作,和在桌面端做法基本一致。 首先,使用 MediaDevices.getUserMedia() 方法獲取攝像頭媒體流,并將其傳遞給 <video> 標簽進行渲染。 接著,使用 HTML 的 < ......

    uj5u.com 2023-01-12 07:58:22 more
  • 記錄--短視頻滑動播放在 H5 下的實作

    這里給大家分享我在網上總結出來的一些知識,希望對大家有所幫助 短視頻已經無數不在了,但是主體還是使用 app 來承載的。本文講述 H5 如何實作 app 的視頻滑動體驗。 無聲勝有聲,一圖頂百辯,且看下圖: 網址鏈接(需在微信或者手Q中瀏覽) 從上圖可以看到,我們主要實作的功能也是本文要講解的有: ......

    uj5u.com 2023-01-04 07:29:05 more
  • 一文讀懂 HTTP/1 HTTP/2 HTTP/3

    從 1989 年萬維網(www)誕生,HTTP(HyperText Transfer Protocol)經歷了眾多版本迭代,WebSocket 也在期間萌芽。1991 年 HTTP0.9 被發明。1996 年出現了 HTTP1.0。2015 年 HTTP2 正式發布。2020 年 HTTP3 或能正... ......

    uj5u.com 2022-12-24 06:56:02 more
  • 【HTML基礎篇002】HTML之form表單超詳解

    ??一、form表單是什么

    ??二、form表單的屬性

    ??三、input中的各種Type屬性值

    ??四、標簽 ......

    uj5u.com 2022-12-18 07:17:06 more