資源簡介
包含數據結構上機課程全部上機內容,如棧、隊列、排序、搜索等各類基本數據結構的建立和功能實現
代碼片段和文件信息
#include?
#include?
#include?
using?namespace?std;
//堆存儲表示************************************************************************************
#define?TRUE?1
#define?OK?1
#define?FALSE?0
#define?ERROR?0
#define?OVERFLOW?-2?
#define?MAXSTRLEN?255
typedef?unsigned?char?SString[MAXSTRLEN+1];
typedef?int?Status;
typedef?struct?{
char?*ch;
int?length;
}HString;
Status?StrInsert(HString?&S?int?pos?HString?T){
//在串S的第pos個字符之前插入串T
if?(pos<1||pos>S.length+1)?return?ERROR;
if(T.length){
if(!(S.ch=(char?*)realloc(S.ch(S.length+T.length)*sizeof(char))))
exit(OVERFLOW);
for?(int?i=S.length-1;i>=pos-1;--i)
S.ch[i+T.length]=S.ch[i];
for?(int?j=pos-1;j<=pos+T.length-2;j++)
S.ch[j]=T.ch[j-pos+1];
S.length+=T.length;
}
return?OK;
}//StrInsert
Status?StrAssign(HString?&Tchar?*chars){
//生成值為chars的串T
//if(T.ch)?free(T.ch);
int?i;char?*c;?
for(i=0c=chars;*c;++i++c);//求chars長度i
if(!i)?{T.ch=NULL;?T.length=0;}
else??{
if(!(T.ch=(char?*)malloc(i*sizeof(char))))
exit?(OVERFLOW);
for(int?j=0;j<=i-1;j++){
T.ch[j]=chars[j];
}
T.length=i;
}
return?OK;
}//StrAssign
int?StrLength(HString?S)?{
//求串長度
return?S.length;
}//StrLength
int?StrCompare(HString?S?HString?T){
//比較串S和T
for?(int?i=0;i if(S.ch[i]!=T.ch[i])?return?S.ch[i]-T.ch[i];
return?S.length-T.length;
}//StrCompare
Status?ClearString(HString?&S){
//清空串S
if(S.ch)?{free(S.ch);?S.ch=NULL;}
S.length=0;
return?OK;
}//ClearString
//
Status?Concat(HString?&THString?S1HString?S2)?{
//連接串S1和S2
//if(T.ch)?free(T.ch);
if(!(T.ch=(char?*)malloc((S1.length+S2.length)*sizeof(char))))
exit(OVERFLOW);
for(int?i=0;i T.ch[i]=S1.ch[i];
T.length=S1.length+S2.length;
for(int?j=S1.length;j T.ch[j]=S2.ch[j-S1.length];
return?OK;
}//Concat
Status?SubString(HString?&SubHString?Sint?posint?len){
//返回串S中從pos位置起長度為len的子串
if?(pos<1||pos>S.length||len<0||len>S.length-pos+1)
return?ERROR;
//if(Sub.ch)?free(Sub.ch);
if(!len){Sub.ch=NULL;?Sub.length=0;}
else{
Sub.ch=(char?*)malloc(len*sizeof(char));
for(int?i=0;i<=len-1;i++)
Sub.ch[i]=S.ch[pos+i-1];
Sub.length=len;
}
return?OK;
}//SubString
void?printStr(HString?T)
{
????int?i;
????for?(i=0;i ????????cout?<????cout< }
int?index(HString?aHString?bint?pos){
int?i=posj=1;
while(i<=a.length&&j<=b.length){
if(a.ch[i]==b.ch[j]){++i++j;}
else?{i=i-j+2;j=1;}
}
if(j>b.length)?return?i-b.length;
else?return?0;
}?
void?get_next(HString?tint?next[]){
int?i?=1;next[1]=0;int?j=0;
while?(i if(j==0||t.ch[i]==t.ch[j])
{
++i;++j;next[i]=j;
}
else?j=next[j];
}
}
int?Index_KMP(HString?sHString?tint?posint?next[])
{
int?i=posj=1;
get_next(tnext);
while(i<=s.length&&j<=t.length){
if(j==0||s.ch[i]==t.ch[j]){
++i;++j;
}
?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
?????目錄???????????0??2018-12-02?22:04??數據結構代碼\
?????目錄???????????0??2018-12-02?22:04??數據結構代碼\串\
?????目錄???????????0??2018-12-17?16:53??數據結構代碼\串\Debug\
?????目錄???????????0??2018-12-02?22:04??數據結構代碼\串\串\
?????目錄???????????0??2018-12-02?22:04??數據結構代碼\串\串\Debug\
?????文件???????74752??2017-10-26?09:53??數據結構代碼\串\串\Debug\vc60.idb
?????文件??????110592??2017-10-26?09:52??數據結構代碼\串\串\Debug\vc60.pdb
?????文件??????553016??2017-10-26?09:52??數據結構代碼\串\串\Debug\串.exe
?????文件??????792756??2017-10-26?09:52??數據結構代碼\串\串\Debug\串.ilk
?????文件??????266634??2017-10-26?09:52??數據結構代碼\串\串\Debug\串.obj
?????文件?????2001512??2017-10-26?08:24??數據結構代碼\串\串\Debug\串.pch
?????文件?????1106944??2017-10-26?09:52??數據結構代碼\串\串\Debug\串.pdb
?????文件????????4527??2017-10-26?09:52??數據結構代碼\串\串\串.cpp
?????文件????????4598??2017-10-26?09:53??數據結構代碼\串\串\串.dsp
?????文件????????1333??2017-10-26?09:52??數據結構代碼\串\串\串.plg
?????文件?????????532??2017-10-26?08:22??數據結構代碼\串\串.dsw
?????文件???????33792??2017-10-26?09:53??數據結構代碼\串\串.ncb
?????文件???????48640??2017-10-26?09:53??數據結構代碼\串\串.opt
?????目錄???????????0??2018-12-02?22:04??數據結構代碼\二叉樹\
?????目錄???????????0??2018-12-17?16:53??數據結構代碼\二叉樹\Debug\
?????目錄???????????0??2018-12-02?22:04??數據結構代碼\二叉樹\二叉樹\
?????目錄???????????0??2018-12-02?22:04??數據結構代碼\二叉樹\二叉樹\Debug\
?????文件???????74752??2017-11-09?08:58??數據結構代碼\二叉樹\二叉樹\Debug\vc60.idb
?????文件??????110592??2017-11-09?08:57??數據結構代碼\二叉樹\二叉樹\Debug\vc60.pdb
?????文件??????540740??2017-11-09?08:57??數據結構代碼\二叉樹\二叉樹\Debug\二叉樹.exe
?????文件??????778828??2017-11-09?08:57??數據結構代碼\二叉樹\二叉樹\Debug\二叉樹.ilk
?????文件??????186638??2017-11-09?08:57??數據結構代碼\二叉樹\二叉樹\Debug\二叉樹.obj
?????文件?????2006964??2017-11-09?08:34??數據結構代碼\二叉樹\二叉樹\Debug\二叉樹.pch
?????文件?????1090560??2017-11-09?08:57??數據結構代碼\二叉樹\二叉樹\Debug\二叉樹.pdb
?????文件????????2440??2017-11-09?08:57??數據結構代碼\二叉樹\二叉樹\二叉樹.cpp
?????文件????????4646??2017-11-09?08:58??數據結構代碼\二叉樹\二叉樹\二叉樹.dsp
............此處省略247個文件信息
- 上一篇:EAS測試許可全套license
- 下一篇:site-1.8.22.zip
評論
共有 條評論