#includeiostream
創(chuàng)新互聯(lián)作為成都網(wǎng)站建設(shè)公司,專注成都網(wǎng)站建設(shè)、網(wǎng)站設(shè)計,有關(guān)成都企業(yè)網(wǎng)站建設(shè)方案、改版、費用等問題,行業(yè)涉及成都發(fā)電機(jī)維修等多個領(lǐng)域,已為上千家企業(yè)服務(wù),得到了客戶的尊重與認(rèn)可。
using namespace std;
double poly(double x,unsigned n)
{
if(n==0) return 1;
if(n==1)
{
poly(x,n)=x;
return x;
}
if(n1) return (((2n-1)*x*poly(x,n-1)-(n-1)*poly(x,n-2))/n);
}
int main()
{
double x;
unsigned n;
cinxn;
coutendl;
coutpoly(x,n)endl;
return 0;
}
C語言中的bool函數(shù)是一種判斷表達(dá)式真假的函數(shù),它接受一個參數(shù),參數(shù)可以是表達(dá)式、變量、常量等,并返回一個布爾值(true或false)來表示表達(dá)式的真假。
拓展:使用bool函數(shù)可以簡化C語言程序的開發(fā),在循環(huán)控制中,可以更方便地編寫判斷條件,使程序更加簡潔、易讀。網(wǎng)名:C語言小白。
拓展:C語言作為一門非常重要的編程語言,具有功能強(qiáng)大、易學(xué)易用的特點,是編寫系統(tǒng)軟件、驅(qū)動程序和應(yīng)用軟件的首選語言。學(xué)習(xí)C語言可以為更高級的編程語言打下基礎(chǔ),并且可以為深入理解計算機(jī)系統(tǒng)運行原理提供幫助。
這個poly函數(shù)很奇怪啊,除了百度百科里有點介紹外,其他地方影都沒有,我的c函數(shù)庫里是沒有這個東西,我懷疑他的存在性,個人見解
函數(shù)名: fillpoly
功 能: 畫并填充一個多邊形
用 法: void far fillpoly(int numpoints, int far *polypoints);
int numpoints:多邊形邊數(shù)
int far *polypoints:存儲各頂點坐標(biāo)的數(shù)組,每兩個一組表示一個頂點的X,Y坐標(biāo)
程序例:
#include graphics.h
#include stdlib.h
#include stdio.h
#include conio.h
int main(void)
{
/* request auto detection */
int gdriver = DETECT, gmode, errorcode;
int i, maxx, maxy;
/* our polygon array */
int poly[8];
/* initialize graphics, local variables */
initgraph(gdriver, gmode, "");
/* read result of initialization */
errorcode = graphresult();
if (errorcode != grOk)
/* an error occurred */
{
printf("Graphics error: %s\n",
grapherrormsg(errorcode));
printf("Press any key to halt:");
getch();
exit(1);
/* terminate with an error code */
}
maxx = getmaxx();
maxy = getmaxy();
poly[0] = 20; /* 1st vertext */
poly[1] = maxy / 2;
poly[2] = maxx - 20; /* 2nd */
poly[3] = 20;
poly[4] = maxx - 50; /* 3rd */
poly[5] = maxy - 20;
/*
4th vertex. fillpoly automatically
closes the polygon.
*/
poly[6] = maxx / 2;
poly[7] = maxy / 2;
/* loop through the fill patterns */
for (i=EMPTY_FILL; iUSER_FILL; i++)
{
/* set fill pattern */
setfillstyle(i, getmaxcolor());
/* draw a filled polygon */
fillpoly(4, poly);
getch();
}
/* clean up */
closegraph();
return 0;
}
功
能:
根據(jù)參數(shù)產(chǎn)生一個多項式
用
法:
double
poly(double
x,
int
n,
double
c[]);
程序例:
#include
#include
/*
polynomial:
x**3
-
2x**2
+
5x
-
1
*/
int
main(void)
{
double
array[]
=
{
-1.0,
5.0,
-2.0,
1.0
};
double
result;
result
=
poly(2.0,
3,
array);
printf("The
polynomial:
x**3
-
2.0x**2
+
5x
-
1
at
2.0
is
%lf\n",
result);
return
0;
}
網(wǎng)頁標(biāo)題:c語言poly函數(shù)怎么用 cyclpoly函數(shù)
文章路徑:http://muchs.cn/article0/hphsio.html
成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供移動網(wǎng)站建設(shè)、網(wǎng)頁設(shè)計公司、App開發(fā)、網(wǎng)站設(shè)計、Google、網(wǎng)站策劃
聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請盡快告知,我們將會在第一時間刪除。文章觀點不代表本網(wǎng)站立場,如需處理請聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時需注明來源: 創(chuàng)新互聯(lián)