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

📄 function.h

📁 数值分析 一个上学的时候经常会到的小小的程序。希望对大家有一点的帮助。
💻 H
字号:
#include<iostream.h>
#include<math.h>
#include<stdlib.h>
#include<string.h>
double dps=1e-10;
const int maxsize=65531;
void swap(double &a,double &b)
{
	double temp=a;
	 a=b;
	  b=temp;
}
void make2darray(double **&x,int rows,int cols)
{ 
	x=new double*[rows];
     for(int i=0;i<rows;i++) 
	  x[i]=new double[cols];
}
void delete2darray(double ** &x,int rows)
{ 
	for(int i=0;i<rows;i++)
      delete[] x[i];
        delete []x;
          x=0;
}
void menu()
{
	 cout<<"                         请选择你要操作的选项!"<<endl;
	 cout<<"  一:计算多项式(press '1')               二:牛顿插值公式(press    '2')"<<endl;
	 cout<<"  三:计算积分  (press '3')               四:牛顿法开方  (press    '4')"<<endl;         
	 cout<<"  五:方程求解  (press '5')               六: 退出        (press others)"<<endl;
}
void submenu3()
{
	cout<<"                         请选择你要操作的选项!"<<endl;
	cout<<"  一:复化梯形法(press '1')                 二: 复化simpson法(press    '2')"<<endl;
	cout<<"  三:变步长梯形(press '3')                 四: 返回上级采单 (press others)"<<endl;
}
void submenu5()
{
	cout<<"                         请选择你要操作的选项!"<<endl;
	cout<<"  一:Jacob方法 (press '1')                 二: G_s方法      (press    '2')"<<endl;
	cout<<"  三:列主元素法(press '3')                 四: 返回上级采单 (press others)"<<endl;
}
void cls()
{
  char	clear[4]="cls";
	system(clear);
}
void title()
{
	cout<<"      -------------------------------------------------------------------"<<endl;
	cout<<"      ︳              挒洑邼嗊 数值分析上机程序 =!1O8                    ︳"<<endl;                 
	cout<<"      -------------------------------------------------------------------"<<endl;
}
void show(double **ch,int n,int m,int flag)
{
	if(flag)
		cout<<"消元后的方程为:"<<endl;
	   else
	     cout<<"要求解的方程组为:"<<endl;
		   for(int i=0;i<n;i++)
		   {
			   for(int j=0;j<m;j++)
			   {
				   if(fabs(ch[i][j])>dps)
				   {
					   if(fabs(ch[i][j]+1)<dps)
						   cout<<"-";
					     else
							 cout<<ch[i][j];
				               cout<<"Y"<<j+1;
				   }
				     else
						 cout<<"    ";
				    if(ch[i][j+1]>0)
						cout<<"+";
			   }
			   cout<<'\b'<<"="<<ch[i][n]<<endl;
		   }
}
void showdiedai(double **ch,int n,int m)
{
	     cout<<"迭代方程为:"<<endl;
			    for(int i=0;i<n;i++)
				{
					cout<<"Y"<<i+1<<"=";
					for(int j=0;j<m;j++)
					{
						if(i!=j)
						{
						 if(fabs(ch[i][j]+1)<dps)
							 cout<<"-";
						  else
							  cout<<ch[i][j];
						        cout<<"Y"<<j+1;
						}
						 if(ch[i][j+1]>0&&i!=j)
							 cout<<"+";
					}
					cout<<ch[i][n]<<endl;
				}
}
void showju(double **ch,double *x,int n)
{
	cout<<"牛顿差商矩阵如下:"<<endl;
    for(int i=0;i<n;i++)
	{
		cout<<"x"<<i<<"="<<x[i]<<"   ";
		 for(int j=0;j<=i;j++)
			 cout<<ch[i][j]<<"   ";
		       cout<<endl;
	}
}

⌨️ 快捷键说明

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