隨機行走 資訊保安演算法設計實驗

2021-09-03 01:44:26 字數 684 閱讀 6031

資訊保安演算法設計實驗之一

//#include "stdafx.h"

#include#include#include#includeusing namespace std;

int a[10][10];

int x, y;

int random()//隨機產生1~3範圍中的乙個數,代表走的方向

void process(int e)//e代表走的方向

if (e == 2)//往左走

if (x >= 2)//還要保證不越界

x--;

if (e == 3)//往右走

if (x <= 7)//還要保證不越界

x++;

}bool judge()//判斷所有三角形是否都已經走過

void print()

}int main()

if (judge())//判斷所有三角形是否都已經走過

else cnt++;

} cout <<"總步數:"

} cout <<"平均次數為:"<< fixed << double(ans) / 100 << endl;

system("pause");

return 0;

}

隨機行走 資料結構演算法實驗

參考部落格 隨機產生0 3範圍中的乙個數,代表走的方向 void process int e e代表走的方向 else 還要判斷是否越界 if x arr y 1 size y row 1 奇數三角形小於該行三角形個數且不是最後一行 if y row if e 2 往左走 if x 2 保證不越界 ...

UNO紙牌(資訊保安演算法設計實驗)

資訊保安演算法設計實驗之一,只具有uno紙牌的部分規則功能 include stdafx.h include include include include include includeusing namespace std struct node int n vectorcard vectorh...

資訊保安實驗 DES演算法

不喜歡這門課,感覺太蛋疼了,不爽。這是第乙個實驗的 還沒完成就因為特殊原因終止了,只實現了加密部分,還沒介面。發上來留個紀念。include include using namespace std 各種表 const int ip table 8 8 const int e table 8 6 co...