資源簡(jiǎn)介
數(shù)據(jù)結(jié)構(gòu)實(shí)驗(yàn)源碼。包括:帶括號(hào)的算術(shù)表達(dá)式求值+A Text Editor Imlementation+Huffman編碼+拓?fù)渑判?-----打印輸出計(jì)算機(jī)本科專業(yè)4年每學(xué)期的課表
代碼片段和文件信息
#include?
#include?
#include?
#include?
using?namespace?std;
string?transform(string?str)//將中綴表達(dá)式轉(zhuǎn)換為后綴表達(dá)式
{
stack?ope;
int?i;
string?exp=““;
for(i=0;i {
if(str[i]==‘.‘||isdigit(str[i]))
{
exp+=str[i];
}
else?if(str[i]==‘+‘||str[i]==‘-‘)
{
int?j=i-1;
if(isdigit(str[j]))
{
exp+=“?“;//每個(gè)數(shù)字的后面都加一個(gè)空格加以區(qū)分
if(ope.empty()||ope.top()==‘(‘)
{
ope.push(str[i]);
}
else
{
while(!ope.empty()&&ope.top()!=‘(‘)
{
exp+=ope.top();
ope.pop();
}
ope.push(str[i]);
}
}
else
{
if(ope.empty()||ope.top()==‘(‘)
{
ope.push(str[i]);
}
else
{
while(!ope.empty()&&ope.top()!=‘(‘)
{
exp+=ope.top();
ope.pop();
}
ope.push(str[i]);
}
}
}
else?if(str[i]==‘*‘||str[i]==‘/‘||str[i]==‘%‘)
{???
int?j=i-1;
if(isdigit(str[j]))
{
exp+=“?“;
if(ope.empty()||ope.top()==‘(‘||ope.top()==‘+‘||ope.top()==‘-‘)
????{
ope.push(str[i]);
????}
????else
????{
?????while(!ope.empty()&&ope.top()!=‘(‘&&ope.top()!=‘+‘&&ope.top()!=‘-‘)
????{
exp+=ope.top();
ope.pop();
????}
ope.push(str[i]);
????}
}
else
{
if(ope.empty()||ope.top()==‘(‘||ope.top()==‘+‘||ope.top()==‘-‘)
{
ope.push(str[i]);
}
else
{
while(!ope.empty()&&ope.top()!=‘(‘&&ope.top()!=‘+‘&&ope.top()!=‘-‘)
{
exp+=ope.top();
ope.pop();
}
ope.push(str[i]);
}
}
}
//}
else?if(str[i]==‘^‘)
{
int?j=i-1;
if(str[j]!=‘)‘)
{
exp+=“?“;
}
ope.push(str[i]);
}
else?if(str[i]==‘(‘)
{
ope.push(str[i]);
}
else?if(str[i]==‘)‘)
{
exp+=“?“;
while(ope.top()!=‘(‘)
{
exp+=ope.top();
ope.pop();
}
ope.pop();
}
else
{
return?“有錯(cuò)誤“;
}
}
while(!ope.empty())//遍歷完表達(dá)式將堆棧中的所有運(yùn)算符輸出
{??
if(isdigit(exp[exp.length()-1]))
{
exp=exp+“?“+ope.top();
????ope.pop();
}
????else
{?
exp=exp+ope.top();
????ope.pop();
}
}
return?exp;
}
int?examine(string?str)//檢查輸入的表達(dá)式是否有誤
{
if((isdigit(str[str.length()-1])!=0||str[str.length()-1]==‘)‘)&&(isdigit(str[0])!=0||str[0]==‘+‘||str[0]==‘-‘||str[0]==‘(‘))
{
int?i;
for(i=0;i {
if(str[i]==‘/‘||str[i]==‘%‘||str[i]==‘*‘||str[i]==‘^‘)
{???
int?a=i+1;
????if(str[a]==‘/‘||str[a]==‘*‘||str[a]==‘%‘||str[a]==‘)‘||str[a]==‘.‘)
{
cout<<“表達(dá)式有錯(cuò)誤“< ????return?1;
????break;
}
}
else?if(str[i]==‘+‘||str[i]==‘-‘)
{
int?a=i+1;
if(str[a]==‘/‘||str[a]==‘*‘||str[a]==‘%‘||str[a]==‘)‘||str[a]==‘.‘||str[a]==‘^‘)
{cout<<“表達(dá)式有錯(cuò)誤“< return?1;
break;}
}
else?if(isdigit(str[i])!=0)
{
int?a=i+1;
if(str[a]==‘(‘)
{
cout<<“表達(dá)式有錯(cuò)誤“< return?1;
break;
}
}
else?if(isdigit(st
?屬性????????????大小?????日期????時(shí)間???名稱
-----------?---------??----------?-----??----
?????目錄???????????0??2019-09-03?19:40??實(shí)驗(yàn)\
?????目錄???????????0??2019-09-03?19:31??實(shí)驗(yàn)\Calculator\
?????文件????????5049??2018-12-17?09:40??實(shí)驗(yàn)\Calculator\main.cpp
?????文件?????2038891??2019-09-03?19:30??實(shí)驗(yàn)\Calculator\main.exe
?????目錄???????????0??2019-09-03?19:33??實(shí)驗(yàn)\classtime
?????文件???????10126??2018-12-19?23:50??實(shí)驗(yàn)\classtime
?????文件?????1977882??2019-09-03?19:33??實(shí)驗(yàn)\classtime
?????文件?????????644??2012-12-11?14:35??實(shí)驗(yàn)\classtime
?????目錄???????????0??2019-09-03?19:39??實(shí)驗(yàn)\editor\
?????目錄???????????0??2019-09-03?19:39??實(shí)驗(yàn)\editor\Debug\
?????文件???????11982??2018-12-12?16:12??實(shí)驗(yàn)\editor\Debug\CL.read.1.tlog
?????文件?????????252??2018-12-12?16:12??實(shí)驗(yàn)\editor\Debug\CL.write.1.tlog
?????文件?????????632??2018-12-12?16:12??實(shí)驗(yàn)\editor\Debug\cl.command.1.tlog
?????文件??????701952??2018-12-14?22:09??實(shí)驗(yàn)\editor\Debug\editor.exe
?????文件?????????406??2018-12-12?16:12??實(shí)驗(yàn)\editor\Debug\editor.exe.em
?????文件?????????472??2018-12-12?16:12??實(shí)驗(yàn)\editor\Debug\editor.exe.em
?????文件?????????381??2018-12-14?22:09??實(shí)驗(yàn)\editor\Debug\editor.exe.intermediate.manifest
?????文件?????1739408??2018-12-14?22:09??實(shí)驗(yàn)\editor\Debug\editor.ilk
?????文件??????????76??2018-12-14?22:09??實(shí)驗(yàn)\editor\Debug\editor.lastbuildstate
?????文件????????1988??2018-12-14?22:09??實(shí)驗(yàn)\editor\Debug\editor.log
?????文件?????2927616??2018-12-14?22:09??實(shí)驗(yàn)\editor\Debug\editor.pdb
?????文件?????????713??2018-12-12?16:12??實(shí)驗(yàn)\editor\Debug\editor.vcxprojResolveAssemblyReference.cache
?????文件???????????0??2018-12-12?16:12??實(shí)驗(yàn)\editor\Debug\editor.write.1.tlog
?????文件?????????208??2018-12-12?16:12??實(shí)驗(yàn)\editor\Debug\editor_manifest.rc
?????文件???????????0??2018-12-17?14:17??實(shí)驗(yàn)\editor\Debug\file_out.txt
?????文件???????????2??2018-12-14?22:09??實(shí)驗(yàn)\editor\Debug\li
?????文件???????????2??2018-12-14?22:09??實(shí)驗(yàn)\editor\Debug\li
?????文件???????????2??2018-12-14?22:09??實(shí)驗(yàn)\editor\Debug\li
?????文件???????????2??2018-12-14?22:09??實(shí)驗(yàn)\editor\Debug\li
?????文件???????????2??2018-12-14?22:09??實(shí)驗(yàn)\editor\Debug\li
?????文件???????????2??2018-12-14?22:09??實(shí)驗(yàn)\editor\Debug\li
............此處省略97個(gè)文件信息
評(píng)論
共有 條評(píng)論