
算法设计与分析
江苏造船厂员工
这个作者很懒,什么都没留下…
展开
-
蚁群算法
%%%%%%%%%%%初始部分,读取图像及计算相关信息%%%%%%%%%%%%%%%%%clear;clc; imgrgb=imread('timg.jpg'); %图像读入imshow(imgrgb),title('显示真彩色图像');imggray=imgrgb;x=rgb2gray(imggray); %将真彩色RGB图像转换成灰度图像figure;imshow(x),title('显示灰度图像');%灰度直方图是将数字图像中的所有像素,按照灰.原创 2021-12-03 14:20:41 · 147 阅读 · 0 评论 -
蚁群算法
%%%%%%%%%%%初始部分,读取图像及计算相关信息%%%%%%%%%%%%%%%%%clear;clc; imgrgb=imread('timg.jpg'); %图像读入imshow(imgrgb),title('显示真彩色图像');imggray=imgrgb;x=rgb2gray(imggray); %将真彩色RGB图像转换成灰度图像figure;imshow(x),title('显示灰度图像');%灰度直方图是将数字图像中的所有像素,按照灰.原创 2021-12-03 14:18:59 · 2192 阅读 · 0 评论 -
遗传算法代码
%**************************************************************************主函数function main()clear allclose allclcglobal chrom oldpop fitness lchrom popsize cross_rate mutation_rate yuzhisumglobal maxgen m n fit gen yuzhi A B C oldpop1 popsize1 b .原创 2021-12-03 14:17:57 · 704 阅读 · 0 评论 -
次序选择问题-分治算法
#include <iostream>#include <cstdlib>//找出一个数组中的第k小元素//启发于快速排序 template <typename T>int sortQuick(T nums[], int low, int hight) { //用随机主元的方式 降低最坏时间复杂度的可能 int index = rand() % (hight - low + 1) + low; //[low,hight] .原创 2021-10-11 17:09:55 · 288 阅读 · 0 评论 -
重复元素全排列-分治法
#include <iostream>#include <cmath>using namespace std;int total = 0;template <typename T>bool check(T nums[], int low, int hight) {//查询是否与前面重复 for (int i = low; i < hight; i++) { if (nums[i] == nums[hight]) { return.原创 2021-10-11 11:51:55 · 269 阅读 · 0 评论 -
分治法求两个大整数相乘(分三段,5次相乘)
import java.awt.*;import java.math.*;import java.util.Scanner;public class homework { public static void main(String[] args){ //输入两个大整数 String strNumA=new Scanner(System.in).nextLine(); String strNumB=new Scanner(System.in)..原创 2021-10-04 23:06:34 · 877 阅读 · 0 评论 -
逆序对计数问题
#include <iostream>#include <vector>#include <cmath>#include <fstream>#include <Windows.h>using namespace std;int nums[] = { 13,8,10,6,15,18,};//12,20,9,14,17,19 bool randNums(int n) { fstream ofs("data.txt", ios::o.原创 2021-10-03 16:40:58 · 112 阅读 · 0 评论 -
最大子数组
#include <iostream>#include <cmath>#include <Windows.h>#include <stdlib.h>#include <fstream>#include <time.h>using namespace std;int nums[12] = { 1,-2,4,5,-2,8,3,-2,6,3,7,-1 };bool randNums(int n) { fstream o.原创 2021-10-03 14:34:08 · 85 阅读 · 0 评论