随笔分类 - 算法
C++算法
二分查找算法
摘要:1、已经排序的数组,查找索引最小的值:int binary_search(int[] array, int n, int value){ int maxIndex = n; int minIndex = 1; int index; while (maxIndex >= minIndex) { index = (maxIndex + minIndex) / 2; if (array[index - 1] == value) { while (--index > 0) { ...
阅读全文
字符串回文算法
摘要:在一个QQ群里看到一位朋友发这个题目:假设称正向读和反向读都相同的字符序列为“回文”,例如,“abba”和“abcba”是回文,“abcde”和“ababab”则不是回文。试设计一个算法判别读入的一个以“@”为结束符的字符序列是否是回文[代码]#inclu...
阅读全文
经典冒泡排序
摘要:代码Code highlighting produced by Actipro CodeHighlighter (freeware)http://www.CodeHighlighter.com/--//冒泡排序方法声明voidSort(intarg[],intlen);intmain(intargc,char*argv[]){intargs[]={2,1,5,4,6,8,3,7};//获取数组的...
阅读全文
高斯消去法
摘要:代码Code highlighting produced by Actipro CodeHighlighter (freeware)http://www.CodeHighlighter.com/--#include"stdio.h"#include"math.h"#include"stdlib.h"typedefdoublearrtype;//高斯消去法voidGuassScale(arrtyp...
阅读全文
如何求出三角形的面积
摘要:1、验证输出参数是否符合要求2、求出三角形面积AreaMath.h Code highlighting produced by Actipro CodeHighlighter (freeware)http://www.CodeHighlighter.com/--#include <math.h>//验证输入的值是否符合要求boolValidateInputValue(doublex,...
阅读全文
如何编写参数个数不定函数
摘要:代码Code highlighting produced by Actipro CodeHighlighter (freeware)http://www.CodeHighlighter.com/--#include<stdio.h>//重要引用#include<stdarg.h>voidsum(char*msg,...);intmain(intargc,char*argv...
阅读全文
关于经典AI算法的问答
摘要:1、什么叫代价值答:代价值:我们暂时理解为起始点到达结束点所消耗的时长。2、如何理解F=G+H等式答:F就是起始点到结束点的距离,我们可以很清楚的知道平面地图就是由N个二维坐标构成的矩阵,既然是由二维坐标构成的话,那么就存在X、Y轴,由此我们就可以设起始点的对象为Start,那么这个Start就存在:Start.X与Start.Y同理我们也可以设结束点(End)为End.X与End.Y,我们取以上...
阅读全文
浙公网安备 33010602011771号