[求人工智能蚁群算法的核心代码]/*ant.c*/#define SPACE 0x20#define ESC 0x1b#define ANT_CHAR_EMPTY '+'#define ANT_CHAR_FOOD 153#define HOME_CHAR 'H'#define FOOD_CHAR 'F'#define FOOD_CHAR2 'f'#d...+阅读
DES虽然不难但是挺繁复的,代码如下,关键点都有英文解释,仔细看。各个函数的功能都可以从函数名看出来。#include "pch.h"#include "misc.h"#include "des.h"NAMESPACE_BEGIN(CryptoPP)/* Tables defined in the Data Encryption Standard documents * Three of these tables, the initial permutation, the final * permutation and the expansion operator, are regular enough that * for speed, we hard-code them. They're here for reference only. * Also, the S and P boxes are used by a separate program, gensp.c, * to build the combined SP box, Spbox[]. They're also here just * for reference. */#ifdef notdef/* initial permutation IP */static byte ip[] = { 58, 50, 42, 34, 26, 18, 10, 2, 60, 52, 44, 36, 28, 20, 12, 4, 62, 54, 46, 38, 30, 22, 14, 6, 64, 56, 48, 40, 32, 24, 16, 8, 57, 49, 41, 33, 25, 17, 9, 1, 59, 51, 43, 35, 27, 19, 11, 3, 61, 53, 45, 37, 29, 21, 13, 5, 63, 55, 47, 39, 31, 23, 15, 7};/* final permutation IP^-1 */static byte fp[] = { 40, 8, 48, 16, 56, 24, 64, 32, 39, 7, 47, 15, 55, 23, 63, 31, 38, 6, 46, 14, 54, 22, 62, 30, 37, 5, 45, 13, 53, 21, 61, 29, 36, 4, 44, 12, 52, 20, 60, 28, 35, 3, 43, 11, 51, 19, 59, 27, 34, 2, 42, 10, 50, 18, 58, 26, 33, 1, 41, 9, 49, 17, 57, 25};/* expansion operation matrix */static byte ei[] = { 32, 1, 2, 3, 4, 5, 4, 5, 6, 7, 8, 9, 8, 9, 10, 11, 12, 13, 12, 13, 14, 15, 16, 17, 16, 17, 18, 19, 20, 21, 20, 21, 22, 23, 24, 25, 24, 25, 26, 27, 28, 29, 28, 29, 30, 31, 32, 1};/* The (in)famous S-boxes */static byte sbox[8][64] = { /* S1 */ 14, 4, 13, 1, 2, 15, 11, 8, 3, 10, 6, 12, 5, 9, 0, 7, 0, 15, 7, 4, 14, 2, 13, 1, 10, 6, 12, 11, 9, 5, 3, 8, 4, 1, 14, 8, 13, 6, 2, 11, 15, 12, 9, 7, 3, 10, 5, 0, 15, 12, 8, 2, 4, 9, 1, 7, 5, 11, 3, 14, 10, 0, 6, 13, /* S2 */ 15, 1, 8, 14, 6, 11, 3, 4, 9, 7, 2, 13, 12, 0, 5, 10, 3, 13, 4, 7, 15, 2, 8, 14, 12, 0, 1, 10, 6, 9, 11, 5, 0, 14, 7, 11, 10, 4, 13, 1, 5, 8, 12, 6, 9, 3, 2, 15, 13, 8, 10, 1, 3, 15, 4, 2, 11, 6, 7, 12, 0, 5, 14, 9, /* S3 */ 10, 0, 9, 14, 6, 3, 15, 5, 1, 13, 12, 7, 11, 4, 2, 8, 13, 7, 0, 9, 3, 4, 6, 10, 2, 8, 5, 14, 12, 11, 15, 1, 13, 6, 4, 9, 8, 15, 3, 0, 11, 1, 2, 12, 5, 10, 14, 7, 1, 10, 13, 0, 6, 9, 8, 7, 4, 15, 14, 3, 11, 5, 2, 12, /* S4 */ 7, 13, 14, 3, 0, 6, 9, 10, 1, 2, 8, 5, 11, 12, 4, 15, 13, 8, 11, 5, 6, 15, 0, 3, 4, 7, 2, 12, 1, 10, 14, 9, 10, 6, 9, 0, 12, 11, 7, 13, 15, 1, 3, 14, 5, 2, 8, 4, 3, 15, 0, 6, 10, 1, 13, 8, 9, 4, 5, 11, 12, 7, 2, 14, /* S5 */ 2, 12, 4, 1, 7, 10, 11, 6, 8, 5, 3, 15, 13, 0, 14, 9, 14, 11, 2, 12, 4, 7, 13, 1, 5, 0, 15, 10, 3, 9, 8, 6, 4, 2, 1, 11, 10, 13, 7, 8, 15, 9, 12, 5, 6, 3, 0, 14, 11, 8, 12, 7, 1, 14, 2, 13, 6, 15, 0, 9, 10, 4, 5, 3, /* S6 */ 12, 1, 10, 15, 9, 2, 6, 8, 0, 13, 3, 4, 14, 7, 5, 11, 10, 15, 4, 2, 7, 12, 9, 5, 6, 1, 13, 14, 0, 11, 3, 8, 9, 14, 15, 5, 2, 8, 12, 3, 7, 0, 4, 10, 1, 13, 11, 6, 4, 3, 2, 12, 9, 5, 15, 10, 11, 14, 1, 7, 6, 0, 8, 13, /* S7 */ 4, 11, 2, 14, 15, 0, 8, 13, 3, 12, 9, 7, 5, 10, 6, 1, 13, 0, 11, 7, 4, 9, 1, 10, 14, 3, 5, 12, 2, 15, 8, 6, 1, 4, 11, 13, 12, 3, 7, 14, 10, 15, 6, 8, 0, 5, 9, 2, 6, 11, 13, 8, 1, 4, 10, 7, 9, 5, 0, 15, 14, 2, 3, 12, /* S8 */ 13, 2, 8, 4, 6, 15, 11, 1, 10, 9, 3, 14, 5, 0, 12, 7, 1, 15, 13, 8, 10, 3, 7, 4, 12, 5, 6, 11, 0, 14, 9, 2, 7, 11, 4, 1, 9, 12, 14, 2, 0, 6, 10, 13, 15, 3, 5, 8, 2, 1, 14, 7, 4, 10, 8, 13, 15, 12, 9, 0, 3, 5, 6, 11};/* 32-bit permutation function P used on the output of the S-boxes */static byte p32i[] = { 16, 7, 20, 21, 29, 12, 28, 17, 1, 15, 23, 26, 5, 18, 31, 10, 2, 8, 24, 14, 32, 27, 3, 9, 19, 13, 30, 6, 22, 11, 4, 25};#endif/* permuted choice table (key) */static const byte pc1[] = { 57, 49, 41, 33, 25, 17, 9, 1, 58, 50, 42, 34, 26, 18, 10, 2, 59, 51, 43, 35, 27, 19, 11, 3, 60, 52, 44, 36, 63, 55, 47, 39, 31, 23, 15, 7, 62, 54, 46, 38, 30, 22, 14, 6, 61, 53, 45, 37, 29, 21, 13, 5, 28, 20, 12, 4};/* number left rotations of pc1 */static const byte totrot[] = { 1,2,4,6,8,10,12,14,15,17,19,21,23,25,27,28};/* permuted choice key (table) */static const byte pc2[] = { 14, 17, 11, 24, 1, 5, 3, 28, 15, 6, 21, 10, 23, 19, 12, 4, 26, 8, 16, 7, 27, 20, 13, 2, 41, 52, 31, 37, 47, 55, 30, 40, 51, 45, 33, 48, 44, 49, 39, 56, 34, 53, 46, 42, 50, 36, 29, 32};/* End of DES-defined tables *//* bit 0 is left-most in byte */static const int bytebit[] = { 0200,0100,040,020,010,04,02,01};/* Set key (initialize key schedule array) */DES::DES(const byte *key, CipherDir dir) : k(32){ SecByteBlock buffer(56+56+8); byte *const pc1m=buffer; /* place to modify pc1 into */ byte *const pcr=pc1m+56; /* place to rotate pc1 into */ byte *const ks=pcr+56; register int i,j,l; int m; for (j=0; j>3] & /* find which key byte l is in */ bytebit[m]) /* and which bit of that byte */ ? 1 : 0; /* and store 1-bit result */ } for (i=0; i
以下为关联文档:
蚁群算法是什么蚁群算法简介 2006-11-2 12:17:00 这两天上课....老师总是提到蚁群算法....听起来似乎很有意思......找到一篇简介.....放在这里有兴趣的朋友...参考一下........ 程序开始...
蚁群算法的相关研究跟着蚂蚁的踪迹,你找到了什么?通过上面的原理叙述和实际操作,我们不难发现蚂蚁之所以具有智能行为,完全归功于它的简单行为规则,而这些规则综合起来具有下面两个方面的特点: 1、多...
关于蚁群算法应用的英文翻译找不到翻译,给你一个算法吧!该程序试图对具有31个城市的VRP进行求解,已知的最优解为784.1,我用该程序只能优化到810左右,应该是陷入局部最优,但我不知问题出在什么地方。请用过蚁...
Prim算法c语言表示求源程序。。。。。。。。我原来自己写的模板 //朴素prim算法 //复杂度 O(n^2) //flag[SIZE] 顶点标记 //mindis[SIZE] 当前最短距离 //dis[SIZE][SIZE] 任意两点间距离 邻接矩阵表示 int prim() { m...
c语言选排列算法该函数求得是自由组合数,输出是An取k的所有可能组合 #include <stdio.h> int n,k,a[10]; long count=0; void perm2(int j) { int i,p,t; if(j==k) //执行条件j=k { for(i=k;...
C语言选择法排序算法问题循环开始 遍历数组 选择j(j初始为0)个元素 赋值p=j循环判断i( j+1到n内)比最小的数 即嵌套循环一旦发现a[p]>a[i]则p=i保持p一直是最小值内层循环结束后可得整个数组前(n-j)个...
数据结构算法c语言迷宫求解注释非常详细,希望对你有所帮助。#include#include#define M 15 #define N 15 struct mark //定义迷宫内点的坐标类型 { int x; int y; }; struct Element //"恋"栈元素,嘿嘿。...
C语言写的迷宫遍历问题没学数据结构写的算法是how to program#include#define X_start 2#define Y_start 0//换了个顺序 #define up 0#define down 2#define right 1#define left 3void mazeTraverse(char maze[][12],int x_start,int...
DES加密算法C语言实现/*********************************************************************//*-文件名:des.h *//*- *//*-功能: 实现DES加密算法的加密解密功能 *//*************************...