Advertisement
SelinD

ex8

May 23rd, 2019
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.68 KB | None | 0 0
  1. #include<iostream>
  2. using namespace std;
  3. int main()
  4. {
  5. int n,i,j,a[25][25],c1=1,c2=1;
  6. cin>>n;
  7. for(i=1; i<=n; i++)
  8. {
  9. for(j=1; j<=n; j++)
  10. {
  11. if(i==j)
  12. {
  13. a[i][j]=0;
  14. }
  15. else
  16. {
  17. if(i<j)
  18. {
  19. a[i][j]=c1;
  20. c1++;
  21. }
  22. else
  23. {
  24. a[i][j]=c2;
  25. c2++;
  26. }
  27. }
  28. }
  29. }
  30. for(i=1; i<=n; i++)
  31. {
  32. for(j=1; j<=n; j++)
  33. cout<<a[i][j]<<" ";
  34. cout<<endl;
  35. }
  36. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement