欧美性猛交XXXX免费看蜜桃,成人网18免费韩国,亚洲国产成人精品区综合,欧美日韩一区二区三区高清不卡,亚洲综合一区二区精品久久

打開(kāi)APP
userphoto
未登錄

開(kāi)通VIP,暢享免費電子書(shū)等14項超值服

開(kāi)通VIP
105.多項式乘法
#include <stdio.h>
#include <math.h>
#define MAX 50
/* 下面的兩個(gè)數組可以根據具體要求解的多項式來(lái)決定其值*/
static double p[6]={4,-6,3,1,-1,5};	/*表示多項式4x^5 - 6x^4 + 3x^3 + x^2 - x + 5 */
static double q[4]={3,2,-5,1};		/*表示多項式3x^3 + 2x^2 - 5x + 1 */
static double result[9]={0,0,0,0,0,0,0,0,0};		/*存放乘積多項式*/

void npmul(p,m,q,n,s)
int m,n;
double p[],q[],s[];
{
	int i,j;
	for (i=0; i<=m-1; i++)
	for (j=0; j<=n-1; j++)
		s[i+j]=s[i+j]+p[i]*q[j];		/*迭帶計算各項系數*/
	return;
}

double compute(s,k,x)					/*計算所給多項式的值*/
double s[];
int k;
float x;
{
	int i;
	float multip = 1;
	double sum = 0;
	for (i=0;i<k;i++)
		multip = multip * x;			/*先求出x的最高次項的值*/
	for (i=k-1;i>=0;i--)
	{
		sum = sum + s[i] * multip;		/*依次從高到低求出相對應次項的值*/
		if (x!=0)
		multip = multip / x;
	}
	return sum;
}

void main()
{
	int i,j,m,n;
	double  px[MAX],qx[MAX],rx[MAX];
	float x;
	clrscr();
	for(i=0;i<MAX;i++)
		rx[i]=0;
	puts("      This is a polynomial multiplication program.");
	puts("It calculate the product of two polynomials: P(x) and Q(x)");
	puts("       P(x)=Pm-1*x^(m-1)+Pm-2*x^(m-2)+...+P1*x+P0");
	puts("       Q(x)=Qn-1*x^(n-1)+Qn-2*x^(n-2)+...+Q1*x+Q0");
	printf("\n >> Please input m (>=1): ");
	scanf("%d",&m);
	printf(" >> Please input P%d, P%d, ... P1, P0 one by one:\n",m-1,m-2);
	for(i=0;i<m;i++)
		scanf("%f",&px[i]);
	printf("\n >> Please input n (>=1): ");
	scanf("%d",&n);
	printf(" >> Please input Q%d, Q%d, ... Q1, Q0 one by one:\n",n-1,n-2);
	for(i=0;i<n;i++)
		scanf("%f",&qx[i]);
	npmul(p,m,q,n,rx);
	printf("\nThe product of two polynomials R(x) is :\n");
	for (i=m+n-1,j=0;i>=1;i--)					/*逐行逐項打印出結果多項式*/
	{
		printf(" (%f*x^%d) + ",rx[m+n-1-i],i-1);
		if(j==2)
		{
			printf("\n");
			j=0;
		}
		else
			j++;
	}
	printf("\n");
	printf("Input the value of x: ");
	scanf("%f",&x);
	printf("\nThe value of the R(%f) is: %13.7f",x,compute(rx,m+n-1,x));
	puts("\n Press any key to quit...");
	getch();
}
本站僅提供存儲服務(wù),所有內容均由用戶(hù)發(fā)布,如發(fā)現有害或侵權內容,請點(diǎn)擊舉報。
打開(kāi)APP,閱讀全文并永久保存 查看更多類(lèi)似文章
猜你喜歡
類(lèi)似文章
方法的定義使用,方法重載及方法的遞歸調用
求和操作
圖像處理之三種常見(jiàn)雙立方插值算法
一維數組的K-Means 聚類(lèi)算法JAVA實(shí)現
C#函數的參數傳遞方式1(值傳遞與地址傳遞)
union初探 MessageMapFunctions
更多類(lèi)似文章 >>
生活服務(wù)
分享 收藏 導長(cháng)圖 關(guān)注 下載文章
綁定賬號成功
后續可登錄賬號暢享VIP特權!
如果VIP功能使用有故障,
可點(diǎn)擊這里聯(lián)系客服!

聯(lián)系客服

欧美性猛交XXXX免费看蜜桃,成人网18免费韩国,亚洲国产成人精品区综合,欧美日韩一区二区三区高清不卡,亚洲综合一区二区精品久久