原创文章,转载请注明:八皇后问题-回溯法(MATLAB) By Lucio.Yang 1.问题描述 八皇后问题是十九世纪著名数学家高斯于1850年提出的.问题是:在8*8的棋盘上摆放8个皇后,使其不能互相攻击,即任意的两个皇后不能处在同意行,同一列,或同意斜线上. 2.matlab代码 function PlaceQueen(row,stack,N)%回溯法放置皇后 if row>N PrintQueen(N,stack);%打印棋盘 else for col=1:N stack(row)=co
tic; % this method is transform from Ritz method %is used for solving two point BVP %this code was writen by HU.D.dong in February 11th 2017 %MATLAB 7.0 clear clc N=50; h=1/N; X=0:h:1; f=inline('pi^2/2*sin(pi/2*x)'); %以下是右端向量: for i=2:N fun1=@(x) f(X
tic; % this method is transform from Galerkin method %also call it as finit method %is used for solving two point BVP which is the first and second term. %this code was writen by HU.D.dong in February 11th 2017 %MATLAB 7.0 clear; clc; N=50; h=1/N; X=