91av视频/亚洲h视频/操亚洲美女/外国一级黄色毛片 - 国产三级三级三级三级

  • 大小: 9KB
    文件類型: .cpp
    金幣: 1
    下載: 1 次
    發(fā)布日期: 2021-06-18
  • 語言: C/C++
  • 標(biāo)簽: 多項(xiàng)式??

資源簡介

編程實(shí)現(xiàn)以下功能: ①分別輸入一元多項(xiàng)式pn (x)和Q n (x)。 從鍵盤輸入一元對項(xiàng)式中各項(xiàng)的系數(shù)和指數(shù),并用單鏈表加以表示。 ②分別對一元多項(xiàng)式pn (x)和Q n (x)進(jìn)行升冪排序。 將一元多項(xiàng)式中各子項(xiàng)按照指數(shù)從小到大的順序排序。 ③分別輸出一元多項(xiàng)式pn (x)和Q n (x)。 將用單鏈表表示的一元多項(xiàng)式輸出,即打印多項(xiàng)式的系數(shù)和指數(shù)。 ④任意輸入一個(gè)實(shí)數(shù)x0,分別求出一元多項(xiàng)式pn (x0)和Q n (x0)的值。 ⑤已知有兩個(gè)一元多項(xiàng)式分別為Pn (x)和Qn (x),求出兩個(gè)多項(xiàng)式的和 R n (x)和差T n (x),分別用單鏈表表示R n (x)和T n (x),并將二者輸出, (R n (x)=P n (x)+Q n (x),T n (x)=P n (x)-Q n (x)) ⑥保存多項(xiàng)式,即分別將一元多項(xiàng)式pn (x)和Q n (x)各項(xiàng)的系數(shù)和指數(shù)保存到外部磁盤文件。 ⑦由程序從所存文件中讀出多項(xiàng)式的系數(shù)和指數(shù),重新構(gòu)建一元多項(xiàng)式 Pn (x) 和Q n (x),并可對其再次進(jìn)行運(yùn)算操作。

資源截圖

代碼片段和文件信息

#include??
#include??
#include????
typedef?struct?duoxiangshi?
{??????
int?coef;?????
int?exp;??????
struct?duoxiangshi?*next;?
}DXS;???
int?getNum()?
{??????
int?num;??????
printf(“輸入選擇功能對應(yīng)的數(shù)字:?“);?????
scanf(“%d“?&num);???????
return?num;?
}???
void?fun1(?DXS?*PHEAD?DXS?*QHEAD?)
{??????
int?zs?xs;//定義指數(shù)系數(shù)?????
printf(“請輸入P(x)中各項(xiàng)的系數(shù)和指數(shù)\n“);?????
scanf(“%d?%d“?&xs?&zs);?????
while(?zs?!=?0?||?xs?!=?0?)???????
{??????????
DXS?*p?=?(DXS*)?malloc(sizeof(DXS));?????????
p->coef?=?xs;????????
p->exp?=?zs;???????????
PHEAD->next?=?p;?????????
p->next?=?NULL;??????????
PHEAD?=?PHEAD->next;??????????
scanf(“%d?%d“?&xs?&zs);?????
}???????
printf(“請輸入Q(x)中各項(xiàng)的系數(shù)和指數(shù)\n“);?
????scanf(“%d?%d“?&xs?&zs);?????
while(?zs?!=?0?||xs?!=?0?)?????
{??????????
DXS?*p?=?(DXS*)?malloc(sizeof(DXS));?????????
p->coef?=?xs;?????????
p->exp?=?zs;???????????
QHEAD->next?=?p;?????????
p->next?=?NULL;?????????
QHEAD?=?p;???????????
scanf(“%d?%d“?&xs?&zs);?????
}???
printf(“輸入5顯示結(jié)果\n“);??
}


void?fun2(?DXS?*PHEAD?DXS?*QHEAD?)//升冪排序?
{??????DXS?*p?*q;//鏈表的冒泡排序???????
p?=?PHEAD->next;??????
for(?p;?p?!=?NULL;?p?=?p->next?)?????
{??????????
for(?q?=?p->next;?q?!=?NULL;?q?=?q->next?)?????????
{??????????????
if(?p->exp?>?q->exp?)?????????????
{?????????????????
int?temp;???????????????????
temp?=?p->coef;?????????????????
p->coef?=?q->coef;?????????????????
q->coef?=?temp;???????????????????
temp?=?p->exp;????????????????
p->exp?=?q->exp;?????????????????
q->exp?=?temp;?????????????
}?????????
}?????
}???????
p?=?QHEAD->next;??????
for(?p;?p?!=?NULL;?p?=?p->next?)?????
{?
?????????for(?q?=?p->next;?q?!=?NULL;?q?=?q->next?)?????????
?{??????????????
?if(?p->exp?>?q->exp?)?????????????
?{??????????????????
?int?temp;???????????????????
?temp?=?p->coef;?????????????????
?p->coef?=?q->coef;?????????????????
?q->coef?=?temp;???????????????????
?temp?=?p->exp;?????????????????
?p->exp?=?q->exp;????????????????
?q->exp?=?temp;?????????????
?}????????
?}?????
}??????
?printf(“輸入5顯示結(jié)果。\n“);??
}


void?fun5(?DXS?*PHEAD?DXS?*QHEAD?)?
{??????
printf(“當(dāng)前保存的P(x)Q(x)序列如下:\n“);???????
printf(“P(x)=“);??????
while(?PHEAD->next?!=?NULL?)?????
{??????????
PHEAD?=?PHEAD->next;??????????
printf(“%d*x^%d“?PHEAD->coef?PHEAD->exp);???????????
if(?PHEAD->next?!=?NULL?)?????????
{??????????????
printf(“?+?“);?????????
}?????
}???????
printf(“\n“);??????
printf(“Q(x)=“);??????
while(?QHEAD->next?!=?NULL?)?????
{??????????
QHEAD?=?QHEAD->next;??????????
printf(“%d*x^%d“?QHEAD->coef?QHEAD->exp);?
????????if(?QHEAD->next?!=?NULL?)?????????
{??????????????
printf(“?+?“);?????????
}?????
}???????
printf(“\n\n“);??
}


void?fun4(?DXS?*PHEAD?DXS?*QHEAD?)?
{??????
int?x0;??????double?sum;???????
pr

評論

共有 條評論

相關(guān)資源