
算法
Solidare
这个作者很懒,什么都没留下…
展开
-
棋盘覆盖问题
#include<iostream> using namespace std; const int n = 8; int tile = 0; int board[n][n] ; //棋盘的中心总为tr+s-1,tc+s-1 tr+s-1,tc+s tr+s,tc+s-1 tr+s,tc+s //tr,tc为递归的启示位置 void chessBoard (int tr,int tc,int dr,int dc,int size) { if(size == 1){原创 2021-05-23 21:38:54 · 197 阅读 · 0 评论 -
二分法搜索
#include<iostream> using namespace std; int BinarySearch(int a[], int x, int n){ //在a[0]<=a[1]<=...<=a[n-1]中搜索x //找到x时返回位置,未找到返回-1 int left = 0; int right = n-1; while(left <= right){ int middle = (left + rig原创 2021-05-23 21:37:00 · 87 阅读 · 0 评论