11.15 樹
二叉樹遍歷-flist
fbi樹
猜數字
cout<<(min+max)/2
<人以群分
最小環
rem name: batch for check就地建堆函式rem author: chen jie
rem date: 2020/10/17
rem description: rename the *.bat file and run it.
rem the batch will consider succesive spaces as one.
@echo off
::no parameter then begin for loop
if"%1"
==""
goto loop
setbat_name
=%~nx0
::bat_name=tfile_name.bat
setfile_name
=%bat_name:~0,-4
%::if no exist the corresponding input file, then end the batch
ifnot
exist
%file_name%
%1.in
(goto end)if
exist
%file_name%
%1.out
(set
ans_name
=%file_name%
%1.out)if
exist
%file_name%
%1.ans
(set
ans_name
=%file_name%
%1.ans
)copy
%file_name%
%1.in %file_name%.in >nul
echo problem test data %1
time
%file_name% < %file_name%.in > %file_name%.out
time
::if exist error, then pause for showing the difference
fc%file_name%.out %ans_name%
/w/n
iferrorlevel1 (
pause>nul
)del
%file_name%.in
del%file_name%.out
::end the batch
goto end
:loop
::call the corresponding data batch
for%%iin(
0123
4567
891011)do
call
%0%%i
echo press any key to exit ...
pause>nul
:end
code到word帶格式複製
查詢二叉樹(tree_a)
對稱二叉樹(tree_c)
合併果子(fruit)
命令引數
基於紅黑樹的可重複集合
multiset<int>st;
st.insert
(a);
cout <<
*st.
begin()
<<
' ';
st.erase
(st.
begin()
);cout <<*(
--st.
end())
<< endl;
st.erase
(--st.
end())
;
看病-hp
小明的賬單-bill
鏟雪車(snow)
珍珠(bead)
int a[5]=;int* p = a;
&(p +2)
;//“&”要求左值&*
(p +2)
;//等於a + 2
遍歷演算法
最小環就是指在一張圖中找出一個環,使得這個環上的各條邊的權值之和最小。在floyed的同時,可以順便算出最小環。記兩點間的最短路為dis[i]
[j],g[i]
[j]為邊的權值。
for(k =
1; k <= n; k++
)answer即為這張圖的最小環。
一個環中的最大結點為k
(編號最大),與它相連的兩個點為i,j,這個環的最短長度為g[i]
[k]+g[k]
[j]+
(i到j的路徑中,所有結點編號都小於k的最短路徑長度)。
根據floyed的原理,在最外層迴圈做了k-
1次之後,dis[i]
[j]則代表了i到j的路徑中,所有結點編號都小於k的最短路徑。
綜上所述,該演算法一定能找到圖中最小環。
kosaraju演算法可以求出有向圖中的強連通分量個數,並且對分屬於不同強連通分量的點進行標記。它的演算法描述較為簡單:憑本事打的表!!(1) 第一次對圖g進行dfs遍歷,並在遍歷過程中,記錄每一個點的退出順序。
(2)倒轉每一條邊的方向,構造出一個反圖g’。然後按照退出順序的逆序對反圖進行第二次dfs遍歷。
每次遍歷得到的那些點即屬於同一個強連通分量。
c. 撕紙條
f. 加減乘除
bool(*check[4]
)(int,
int)
=;
qq截圖複製色號