⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄

📁 收集的C语言算法程序
💻
字号:
#include<iostream>
using namespace std;
#include<math.h>
#define N 5             //以五点为例

void main()
{
int i;

double A,B,x0=0,y0=0,x02=0,x0y0=0,a,b;
double u[N];
double x[N],y[N];
cout<<"Please input the array of x:\n";
for(i=0;i<N;i++)
cin>>x[i];
cout<<"Please input the array of y:\n";
for(i=0;i<N;i++)
cin>>y[i];


for(i=0;i<N;i++) u[i]=log(y[i]);
for(i=0;i<N;i++) {x0+=x[i];x02+=x[i]*x[i];y0+=u[i];x0y0+=x[i]*u[i];}

A=(x0y0-y0*x0/N)/(x02-x0*x0/N);
B=(y0-x0*A)/N;
a=exp(A);
b=B;

cout<<"The established equation is:\n";
cout<<"y="<<a<<"exp("<<b<<"x)";

}

 

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -