資源簡介
西南交大 數據結構 實驗代碼 采用c編寫的

代碼片段和文件信息
#include?
#include
#include
typedef?struct?Item{
??double??coef;
??int?????expn;
??struct?Item?*next;
??}Item*Polyn;
#define?CreateItem(p)?p=(Item?*)malloc(sizeof(Item));
#define?DeleteItem(p)?free((void?*)p);
/************************************************************/
/*?????????????????????判斷選擇函數?????????????????????????*/
/************************************************************/
int?Select(char?*str)
??{?char?ch;
????printf(“%s\n“str);
????printf(“Input?Y?or?N:“);
????do{?ch=getch();
}while(ch!=‘Y‘&&ch!=‘y‘&&ch!=‘N‘&&ch!=‘n‘);
????printf(“\n“);
????if(ch==‘Y‘||ch==‘y‘)?return(1);
????else?return(0);
????}
/************************************************************/
/*????????????????插入位置定位函數??????????????????????????*/
/**************************************************************/
int?InsertLocate(Polyn?hint?expnItem?**p)
??{?Item?*pre*q;
????pre=h;
????q=h->next;
????while(q&&q->expn ??????{?pre=q;
????????q=q->next;
????}
????if(!q)
??????{?*p=pre;
????return(1);
????}
????else?if(q->expn==expn)
??????{?*p=q;
????return(0);
????}
????else
??????{?*p=pre;
????return(-1);
????????}
????}
/************************************************************/
/*?????????????????????插入結點函數?????????????????????????*/
/************************************************************/
void?insert(Item?*preItem?*p)
{
????p->next=pre->next;
????pre->next=p;
????}
/************************************************************/
/*?????????????????????輸入多項式???????????????????????????*/
/************************************************************/
Polyn?Input(void)
{
??double??coef;
??int?????expnflag;
??Item?*h*p*q*pp;
??CreateItem(h);//產生頭結點
??h->next=NULL;
??printf(“input?coef?and?expn(if?end?expn=-1)\n“);
??while(1)
??{
????scanf(“%lf%d“&coef&expn);?//輸入多項式的系數和指數
????if(expn==-1)?break;?????????//若指數為-1,表示輸入結束
????if(InsertLocate(hexpn&pp))//返回值非0表示插入新結點
?????{?CreateItem(p);
???????p->coef=coef;
???????p->expn=expn;
???????insert(ppp);
???????}
?????else?if(Select(“has?the?same?expnReplace?older?value?“))?
??pp->coef=coef;??//指數相同,替換系數
?????}
??return?h;
??}
/************************************************************/
/*?????????????????????撤消多項式???????????????????????????*/
/************************************************************/
void?Destroy(Polyn?h)
{
??Item?*p=h*q;
??while(p!=NULL)
??{
????q=p;
????p=p->next;
????DeleteItem(q);
????}
??}
/************************************************************/
/*?????????????????????輸出多項式???????????????????????????*/
/************************************************************/
void?Output(Polyn?hchar?*title)
{
??int?flag=1;
??Item?*p=h->next;
??printf(“%s=“title);
??while(p)
??{?if(flag)????//表示是否是多項式的第一項
??????{?flag=0;
???if(p->expn==0)? printf(“%.2lf“p->coef);
???else?printf(“%.2lfx^%d“p->coefp->expn);
???}
????else
???
?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
?????目錄???????????0??2014-04-20?18:19??數據結構實驗?-?副本\
?????目錄???????????0??2014-04-20?18:19??數據結構實驗?-?副本\數據結構??實驗一\
?????文件???????10750??2013-12-06?09:41??數據結構實驗?-?副本\數據結構??實驗一\1.cpp
?????目錄???????????0??2014-04-20?18:19??數據結構實驗?-?副本\數據結構??實驗一\Debug\
?????文件???????24595??2013-09-15?11:48??數據結構實驗?-?副本\數據結構??實驗一\Debug\1.obj
?????文件???????33792??2013-09-15?11:48??數據結構實驗?-?副本\數據結構??實驗一\Debug\vc60.idb
?????文件???????53248??2013-09-15?11:48??數據結構實驗?-?副本\數據結構??實驗一\Debug\vc60.pdb
?????文件??????225353??2013-09-15?11:48??數據結構實驗?-?副本\數據結構??實驗一\Debug\數據結構??實驗一.exe
?????文件??????289776??2013-09-15?11:48??數據結構實驗?-?副本\數據結構??實驗一\Debug\數據結構??實驗一.ilk
?????文件????????4389??2013-09-15?11:28??數據結構實驗?-?副本\數據結構??實驗一\數據結構??實驗一.dsp
?????文件?????????540??2013-09-15?11:28??數據結構實驗?-?副本\數據結構??實驗一\數據結構??實驗一.dsw
?????文件???????41984??2013-09-15?11:49??數據結構實驗?-?副本\數據結構??實驗一\數據結構??實驗一.ncb
?????文件???????48640??2013-09-15?11:49??數據結構實驗?-?副本\數據結構??實驗一\數據結構??實驗一.opt
?????文件????????2086??2013-09-15?11:48??數據結構實驗?-?副本\數據結構??實驗一\數據結構??實驗一.plg
?????文件?????1855488??2013-12-06?09:37??數據結構實驗?-?副本\數據結構??實驗一\數據結構??實驗一.sdf
?????文件????????6242??2013-12-06?09:37??數據結構實驗?-?副本\數據結構??實驗一\數據結構??實驗一.vcxproj
?????文件?????????897??2013-12-06?09:37??數據結構實驗?-?副本\數據結構??實驗一\數據結構??實驗一.vcxproj.filters
?????文件?????????143??2013-12-06?09:37??數據結構實驗?-?副本\數據結構??實驗一\數據結構??實驗一.vcxproj.user
?????目錄???????????0??2014-04-20?18:19??數據結構實驗?-?副本\數據結構??實驗七\
?????目錄???????????0??2014-04-20?18:19??數據結構實驗?-?副本\數據結構??實驗七\Debug\
?????文件???????36352??2013-12-13?20:46??數據結構實驗?-?副本\數據結構??實驗七\Debug\數據結構??實驗七.exe
?????文件??????345276??2013-12-13?20:46??數據結構實驗?-?副本\數據結構??實驗七\Debug\數據結構??實驗七.ilk
?????文件??????379904??2013-12-13?20:46??數據結構實驗?-?副本\數據結構??實驗七\Debug\數據結構??實驗七.pdb
?????目錄???????????0??2014-04-20?18:19??數據結構實驗?-?副本\數據結構??實驗七\ipch\
?????目錄???????????0??2014-04-20?18:19??數據結構實驗?-?副本\數據結構??實驗七\ipch\數據結構??實驗七-608c9497\
?????文件?????2097152??2013-12-26?00:01??數據結構實驗?-?副本\數據結構??實驗七\ipch\數據結構??實驗七-608c9497\數據結構??實驗七-9fa7ecce.ipch
?????目錄???????????0??2014-04-20?18:19??數據結構實驗?-?副本\數據結構??實驗七\數據結構??實驗七\
?????文件?????1986560??2013-12-26?00:02??數據結構實驗?-?副本\數據結構??實驗七\數據結構??實驗七.sdf
?????文件?????????936??2013-12-12?23:32??數據結構實驗?-?副本\數據結構??實驗七\數據結構??實驗七.sln
?????文件???????11776??2013-12-26?00:02??數據結構實驗?-?副本\數據結構??實驗七\數據結構??實驗七.suo
?????文件???????14423??2013-12-13?20:46??數據結構實驗?-?副本\數據結構??實驗七\數據結構??實驗七\1.cpp
............此處省略178個文件信息
評論
共有 條評論