Jump to content

Recommended Posts

  • Moderators
Posted

Mama ei de matrice.

 

 

7sC8aqU.png

 

 

Pana am ajuns la formula din final cu 2*n-(i+j)+1 mi-am ars creieru' :))

#include <iostream>
using namespace std;
int main(void)
{
    int i,j,a[30][30],n;
    cin>>n;
    for (i=1;i<=n;i++)
        for (j=1;j<=n;j++)
            if (i+j<=n)
                a[i][j]=i+j-1;
            else
                if (i+j==n+1)
                    a[i][j]=n;
                else
                    a[i][j]=2*n-(i+j)+1;
    for (i=1;i<=n;i++)
    {
        for (j=1;j<=n;j++)
            cout<<a[i][j]<<" ";
        cout<<endl;
    }
}

Posted

Ai mai putea sa faci simetrie fata de diagonala secundara, daca ti-e greu sa gasesti formule, la BAC esti cam stresat.

for(i=1;i<=n;i++)
for(j=1;j<=n-i+1;j++)
a[i][j]=i+j-1;
for(i=2;i<=n;i++)for(j=n;j>n-i+1;j--) a[i][j]==a[n-j+1][n-i+1];

or some shit like that

fWy1P.gif

 

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.