Advertisement
Dizzy3113

Untitled

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