随笔分类 - 我的数据结构学习之路
摘要:折半查找迭代算法: #include <iostream>//迭代的方法:using namespace std;//*a传递数组,x为传递的要查找的数,n为数据的个数int erfen(int *a,const int x,const int n);int main(){ int a[]={1,2
阅读全文
摘要:折半查找递归算法跟迭代算法: #include <iostream>using namespace std;int diedai(int *a,const int x,const int n);int digui(int *a,const int x,const int left,const int
阅读全文
摘要:今天来总结下递归: #include <iostream> using namespace std; void doA(){ cout<<"你好啊"<<endl; doA();}void doB(){ cout<<"从前有座山,山里有座庙,庙里有个老和尚,老和尚再给小和尚讲故事:"<<endl; d
阅读全文
摘要:随着学习的深入,才渐渐地发现,自己的基础是多么的差劲。悔不当初,上课的时候就应该多认真听讲了。 多层 for 之间的嵌套使用。虽说是多层,事实上 for 循环嵌套的层数也不能太多。通常为两个 for 循环的嵌套,超过两个的极少使用。与单个 for 循环相比,多个 for 循环的嵌套在逻辑上更复杂一点
阅读全文
摘要:顺序查找: #include <iostream>//顺序查找,速度慢,只能按顺序去查找using namespace std; int shunxu(int *a,const int n,const int x);int main(){ int a[]={2,4,6,8,0,1,3,5,7,9};
阅读全文
摘要:选择排序: #include <iostream>//从当前未排序的正数中找一个最小的整数,将他放在已排好的整数列表中的最后。//要点:选择排序选择最小的,往左边选。using namespace std; void selectsort(int *a,const int n); int main(
阅读全文
摘要:下面是一个冒泡排序,是在swap代码的基础上发展而来的,这应该是最简单的排序了吧,但同时也是效率最低的一个了吧: #include <iostream> using namespace std;void bubblesort(int list[],int n);int main(){int a[]=
阅读全文
摘要:swap交换:swap是几乎所有的排序的最基础部分,代码如下: #include <iostream> using namespace std; int main(){int a,b,tmp;a=1;b=10;cout <<"a="<< a<<",b="<<b<< endl;tmp=a;a=b;b=
阅读全文

浙公网安备 33010602011771号