Shamba

Soluchan

Feb 20th, 2018
117
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.64 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. using namespace std;
  4. void show(int array[][40],int a)
  5. {
  6.     int i,j;
  7.     for(i=0;i<a;i++)
  8.     {
  9.         for(j=0;j<a;j++)
  10.         {
  11.             if(i==j)
  12.             {
  13.                 array[i][i]=0;
  14.             }
  15.         }
  16.     }
  17.     for(i=0;i<a;i++)
  18.     {
  19.         for(j=0;j<a;j++)
  20.         {
  21.             cout<<array[i][j]<<" ";
  22.         }
  23.         cout<<"\n";
  24.     }
  25. }
  26.  
  27. int main()
  28. {
  29.     int r,arr[40][40],i,j;
  30.     cout<<"Enter rows and columns : ";
  31.     cin>>r;
  32.     for(i=0;i<r;i++)
  33.     {
  34.         for(j=0;j<r;j++)
  35.         {
  36.             arr[i][j]=j+1;
  37.         }
  38.     }
  39.     show(arr,r);
  40.     return 0;
  41. }
Add Comment
Please, Sign In to add comment