Guest User

Untitled

a guest
Jan 21st, 2018
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.08 KB | None | 0 0
  1. #include <iostream>
  2. using   std::cin;
  3. using   std::cout;
  4. using   std::endl;
  5. #include <conio.h>
  6. double Summ(double b[10][10],int i,int m,double x[10],int o)
  7. {   int k=0; double c=0;
  8.     const int cn=i;
  9.     m--;i++;
  10.     while(k!=o)
  11.     {
  12.         c+=b[cn][m]*x[i];
  13.         i++;m--;k++;
  14.     }
  15.     return c;
  16. }
  17. void Equate(double a[10][10],double b[10][10],int n, int m)
  18. {
  19.     for(int i=0;i<n;i++)
  20.         for(int j=0;j<m;j++)
  21.             a[i][j]=b[i][j];
  22. }
  23. void main()
  24. {    double a[10][10], b[10][10],x[10]={0};
  25.      int i,j,k,n,m,o;
  26.      cout<<"vvedite n"<<endl;
  27.      cin>>n;
  28.      cout<<"vvedite m"<<endl;
  29.      cin>>m;
  30.      for(i=0;i<n;i++)
  31.      {
  32.          for(j=0;j<m;j++)
  33.          { 
  34.              cout<<"Vvedite a["<<i<<","<<j<<"]"<<endl;
  35.              cin>>a[i][j];
  36.          }
  37.      }
  38.  
  39.     for(k=0;k<n;k++)
  40.     {
  41.       for(i=0+k;i<n;i++)
  42.          {
  43.              for(j=0+k;j<m;j++)
  44.              {   
  45.                  
  46.                  b[k][j]=a[k][j]/a[k][k];
  47.                  
  48.                  if(i>k)
  49.                  {
  50.                      b[i][j]=a[i][j]-b[k][j]*a[i][k];
  51.                  }
  52.              }
  53.          }
  54.         Equate(a,b,n,m);
  55.     }
  56.    
  57.     o=0;m--;
  58. for(i=n-1;i>=0;i--)
  59. {
  60.     x[i]=b[i][m]-Summ(b,i,m,x,o);
  61.     o++;
  62. }
  63. for (i=0;i<n;i++)
  64.  cout<<"X["<<i+1<<"] = "<<x[i]<<endl;
  65.  
  66. getch();
  67. }
Add Comment
Please, Sign In to add comment