Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // ConsoleApplication10.cpp: определяет точку входа для консольного приложения.
- //
- #include "stdafx.h"
- #include "iostream"
- #include "math.h"
- #include <iomanip>
- using namespace std;
- double P(double x)
- {
- return x;
- }
- double Q(double x)
- {
- return 1;
- }
- double F(double x)
- {
- return (double) 0;
- }
- int _tmain(int argc, _TCHAR* argv[])
- {
- double a=0,b=1,h;
- int N=5;
- /*cout<<"Vvedite a: \n";
- cin>>a;
- cout<<"Vvedite b: \n";
- cin>>b;
- cout<<"Vvedite N: \n";
- cin>>N;*/
- h = (double) (b-a)/N;
- double *x = new double[N];
- double **y = new double*[N];
- for(int i=0;i<N;i++)
- y[i]=new double [N+2];
- for (int i = 0; i < N; i++)
- {
- x[i]=a+i*h;
- }
- for (int i=0;i<N;i++)
- for(int j=0;j<N+2;j++)
- y[i][j]=0;
- for(int i=1;i<N-1;i++)
- y[i][N+1]=F(x[i]);
- y[0][N+1]=1.0;
- y[N-1][N+1]=0.2233;
- y[0][0]=1;
- y[N-1][N]=1;
- int l = 1;
- while(l<N-1)
- {
- y[l][l] = 1 - (P(x[l+1])*h)/2;
- y[l][l+1]=-2 + h*h*Q(x[l+1]);
- y[l][l+2]=1 + (P(x[l+1])*h)/2;
- l++;
- }
- for (int i=0;i<N;i++)
- {
- for(int k=0;k<=N+1;k++)
- {
- cout << left << setw(8) <<y[i][k];
- }
- cout<<endl;
- }
- system("pause");
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment