Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //se contruieste o matrice patratica
- #include <iostream>
- using namespace std;
- int main()
- {
- int a[100][100],m,i,j,nr;
- cout<<"m= ";cin>>m;
- for (j=1;j<=m;j++)
- {
- if (j%2==1)
- for (i=1;i<=m;i++)
- {
- a[i][j]=nr;
- nr++;
- }
- else
- for (i=m;i>=1;i--)
- {
- a[i][j]=nr;
- nr++;
- }
- }
- for (i=1;i<=m;i++)
- {
- for (j=1;j<=m;j++)
- cout<<a[i][j]<<" ";
- cout<<'\n';
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement