Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using std::cin;
- using std::cout;
- using std::endl;
- #include <conio.h>
- double Summ(double b[10][10],int i,int m,double x[10],int o)
- { int k=0; double c=0;
- const int cn=i;
- m--;i++;
- while(k!=o)
- {
- c+=b[cn][m]*x[i];
- i++;m--;k++;
- }
- return c;
- }
- void Equate(double a[10][10],double b[10][10],int n, int m)
- {
- for(int i=0;i<n;i++)
- for(int j=0;j<m;j++)
- a[i][j]=b[i][j];
- }
- void main()
- { double a[10][10], b[10][10],x[10]={0};
- int i,j,k,n,m,o;
- cout<<"vvedite n"<<endl;
- cin>>n;
- cout<<"vvedite m"<<endl;
- cin>>m;
- for(i=0;i<n;i++)
- {
- for(j=0;j<m;j++)
- {
- cout<<"Vvedite a["<<i<<","<<j<<"]"<<endl;
- cin>>a[i][j];
- }
- }
- for(k=0;k<n;k++)
- {
- for(i=0+k;i<n;i++)
- {
- for(j=0+k;j<m;j++)
- {
- b[k][j]=a[k][j]/a[k][k];
- if(i>k)
- {
- b[i][j]=a[i][j]-b[k][j]*a[i][k];
- }
- }
- }
- Equate(a,b,n,m);
- }
- o=0;m--;
- for(i=n-1;i>=0;i--)
- {
- x[i]=b[i][m]-Summ(b,i,m,x,o);
- o++;
- }
- for (i=0;i<n;i++)
- cout<<"X["<<i+1<<"] = "<<x[i]<<endl;
- getch();
- }
Add Comment
Please, Sign In to add comment