Advertisement
Guest User

Untitled

a guest
Feb 21st, 2020
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.37 KB | None | 0 0
  1. #include <iostream>
  2. #include <iomanip>
  3.  
  4. using namespace std;
  5.  
  6. const int N = 10;
  7. const int M = 400;
  8. const double T = 1.0;
  9. const double L = 1.0;
  10. const double h = L/N;
  11. const double tao = T/M;
  12. const double A = 5;
  13.  
  14. const int C = 5;
  15. const int B = 1;
  16.  
  17. #define UU(x,t) A*B*exp(x*h + t*tao)
  18.  
  19. double f(int x, int t) {
  20.     return ((ro(x, t) - kx(x) - k(x, t)*B - p(x, t) + q(x, t)/B)*B*A*exp(L + t*tao));
  21. }
  22. double k(double x, double t) {
  23.     return (5 + pow(x*tao, 2) + pow(t*tao, 2));
  24. }
  25. double kx(double x) {
  26.     return 2*x*h;
  27. }
  28. double p(double x, double t) {
  29.     return (20 + pow(x*h, 2) + 0.5*pow(t*tao, 2));
  30. }
  31. double q(double x, double t) {
  32.     return (x + 1 + cos(x));
  33. }
  34. double ro(double x, double t) {
  35.     return (10 + x*h + t*tao);
  36. }
  37.  
  38.  
  39. int main() {
  40.     double u[N+1][M+1] = {};
  41.     //Начальное условие
  42.     for(int i=0; i<N+1; i++) {
  43.         u[i][0] = A*exp(B*i*h);
  44.     }
  45.     //Граничные условия
  46.     for(int j=1; j<M+1; j++) {
  47.         u[0][j] = A*exp(j*tao*B);
  48.         u[N][j] = A*exp((L + j*tao)*B);
  49.     }
  50.     double a[N+1], b[N+1], c[N+1], alpha[N+1], beta[N+1];
  51.     for(int j=0; j<M; j++) {
  52.         alpha[0] = 0;
  53.         beta[0] = C * exp(B * j * tao);
  54.         for(int i=1; i<N; i++) {
  55.  
  56.         }
  57.     }
  58.     for(int j=M; j>=0; j--) {
  59.         for(int i=0; i<N+1; i++) {
  60.             cout << setprecision(5) << u[i][j] - UU(i,j) << "\t";  
  61.         }
  62.         cout << endl;
  63.     }
  64.     cout << endl <<endl;
  65.     system("pause");
  66.     return 0;
  67. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement