Advertisement
Eddie_1337

tare conex

Mar 22nd, 2017
136
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.60 KB | None | 0 0
  1. #include <iostream.h>
  2. #include <fstream.h>
  3. int a[20][20];
  4. int main (){
  5.     int i,j,k,n,x,y;
  6.     ifstream f("in.txt");
  7.     f>>n;
  8.     for(i=1;i<=n;i++)
  9.         for(j=1;j<=n;j++)
  10.             f>>a[i][j];
  11.     for(k=1;k<=n;k++)
  12.         for(i=1;i<=n;i++)
  13.             for(j=1;j<=n;j++)
  14.                 if(!a[i][j] && a[i][k] && a[k][j] && i!=k && j!=k)
  15.                     a[i][j]=1;
  16.     for(i=1;i<=n;i++){
  17.         for(j=1;j<=n;j++)
  18.             cout<<a[i][j]<<" ";
  19.         cout<<endl;
  20.     }
  21.     k=1;
  22.     for(i=1;i<=n && k;i++){
  23.         for(j=1;j<=n && k;j++)
  24.             if(i!=j && a[i][j]!=1)
  25.                 k=0;
  26.     }
  27.     if(k)
  28.         cout<<"este tare tare foarte tare conex";
  29.     else
  30.         cout<<"nu este tare tare foarte tare conex";
  31. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement