
数据结构
viease
nothing
展开
-
数据结构-前缀、中缀、后缀表达式
它们都是对表达式的记法,因此也被称为前缀记法、中缀记法和后缀记法。它们之间的区别在于运算符相对与操作数的位置不同:前缀表达式的运算符位于与其相关的操作数之前;中缀和后缀同理。 举例: (3 + 4) × 5 - 6 就是中缀表达式 - × + 3 4 5 6 前缀表达式 3 4 + 5 × 6 - 后缀表达式 中缀表达式(中缀记法) 中缀表达式是一种通用的算术或逻辑公式表示方法转载 2014-08-14 09:14:48 · 3645 阅读 · 2 评论 -
数据结构-串的模式匹配
KMP算法 1.求next[]函数值 next[j]= -1 (j)原创 2014-08-14 09:28:06 · 726 阅读 · 0 评论 -
c++学习之--排序3-快速排序
#include using namespace std; #define N 10 int Partition(int *a,int low,int high) { int temp; temp=a[low]; while(low { while(low { high--; } if(low { a[low]=a[high]; low++;原创 2013-11-20 21:16:26 · 663 阅读 · 0 评论 -
c++学习之--排序5-堆排序
#include using namespace std; // 58 45 72 86 77 21 34 60 void Swap(int *x,int *y) { int t; t=*x; *x=*y; *y=t; } void HeapAdjust(int *a,int i,int size) { int lchild=2*i; int rchild=2*i+1; i原创 2013-11-21 19:32:16 · 620 阅读 · 0 评论 -
c++学习之--排序4-直接选择排序
#include using namespace std; #define N 10 void XzSort(int *a,int n) { int i,j,min_i,t; for(i=0;i { min_i=i; for(j=i+1;j { if(a[min_i]>a[j]) { min_i=j; } } if(min_i!=i) { t=原创 2013-11-20 21:17:03 · 756 阅读 · 0 评论 -
c++学习之--排序1-冒泡排序
#include using namespace std; #define N 10 void MpSort(int *a,int n) { int i,j; for(i=0;i<n-1;i++) { for(j=0;j<n-1-i;j++) { if(a[j]>a[j+1]) { a[j]=a[j]+a[j+1]; a[j+1]=a[j]-原创 2013-11-20 21:14:53 · 729 阅读 · 0 评论 -
c++学习之--排序2-直接插入排序
#include using namespace std; #define N 10 void CrSort(int *a,int n) { int i,t; for(i=1;i<n;i++) { t=a[i]; while(t<a[i-1] && i) { a[i]=a[i-1]; i--; } a[i]=t; } } int main() {原创 2013-11-20 21:15:40 · 738 阅读 · 0 评论