Advertisement
STANAANDREY

pivot_mat

May 8th, 2019
289
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.41 KB | None | 0 0
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. int main() {
  5.  
  6. int a[100][100],n,i,j,p=1,ok=1;
  7. float x;
  8. cout<<"n=";cin>>n;
  9. for (i=0;i<n;i++)
  10.     for (j=0;j<n;j++)
  11.     cin>>a[i][j];
  12.     for (i=1;i<n;i++) {
  13.     x=(float)a[0][i]/(float)a[0][0];
  14.     ok=1;
  15.     for (j=1;j<n&&ok;j++)
  16.         if ((float)a[j][i]/(float)a[j][0]!=x)
  17.         ok=0;
  18.         if (ok)
  19.          p*=x;
  20. }
  21. cout<<"prod="<<p;
  22.  
  23.   return 0;
  24. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement