Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <cmath>
- using namespace std;
- int a[101][101], n;
- void ordonare_matrice(int n)
- {
- int i, j;
- for(i=0; i<n; i++)
- for(j=0; j<n; j++)
- {
- if(i==j || i+j==n-1)
- a[i][j]=0;
- else if(i+j<n)
- a[i][j]=i+j;
- else
- a[i][j]=abs((n-1)-(i+j));
- }
- }
- void afisare_matrice(int n)
- {
- int i, j;
- for(i=0; i<n; i++)
- {
- for(j=0; j<n; j++)
- cout<<a[i][j]<<' ';
- cout<<'\n';
- }
- }
- int main()
- {
- cin>>n;
- ordonare_matrice(n);
- afisare_matrice(n);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment