Advertisement
icatalin

construirea matrice

May 13th, 2014
193
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.49 KB | None | 0 0
  1. //se contruieste o matrice patratica
  2.  
  3. #include <iostream>
  4.  
  5. using namespace std;
  6.  
  7. int main()
  8. {
  9. int a[100][100],m,i,j,nr;
  10. cout<<"m= ";cin>>m;
  11. for (j=1;j<=m;j++)
  12. {
  13. if (j%2==1)
  14. for (i=1;i<=m;i++)
  15. {
  16. a[i][j]=nr;
  17. nr++;
  18. }
  19. else
  20. for (i=m;i>=1;i--)
  21. {
  22. a[i][j]=nr;
  23. nr++;
  24. }
  25. }
  26. for (i=1;i<=m;i++)
  27. {
  28. for (j=1;j<=m;j++)
  29. cout<<a[i][j]<<" ";
  30. cout<<'\n';
  31. }
  32. return 0;
  33. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement