Rezultati

Up. imeNalogaJezikRezultatČas oddaje
lml-2018 Kvadrat števil C++ 100/100OK 13. okt '18 @ 11:37

Test Točke Porabljen spomin Porabljen čas Status
#1 10/10 1,461 MiB 0,000 s OK
#2 10/10 1,496 MiB 0,000 s OK
#3 10/10 1,496 MiB 0,005 s OK
#4 10/10 1,492 MiB 0,005 s OK
#5 10/10 1,492 MiB 0,000 s OK
#6 10/10 1,480 MiB 0,005 s OK
#7 10/10 1,563 MiB 0,004 s OK
#8 10/10 1,559 MiB 0,010 s OK
#9 10/10 1,648 MiB 0,010 s OK
#10 10/10 1,566 MiB 0,004 s OK

Ocenjevani program (Kvadrat.cpp):
#include <stdio.h>
#include <algorithm>

using namespace std;

int izpis[100][100];
int nums[10000];

int compare(const void* p1, const void* p2)
{
    return *((int*)(p1)) - *((int*)(p2));
}

int main()
{
    int n;
    scanf("%d",&n);
    int e = n * n;

    for(int i = 0; i < e; i++)
    {
        scanf("%d",&nums[i]);
    }

    qsort(nums,e,sizeof(int),compare);

    int s = n/2;
    int s1 = s;
    int count = n * n - 1;

    for(int i = s; i >= 0; i--)
    {
        for(int j = s; j < n; j++)
        {
            izpis[i][j] = nums[count];
            count--;
        }

        for(int j = s - 1; j >= 0; j--)
        {
            izpis[i][j] = nums[count];
            count--;
        }
    }

    for(int i = s + 1; i < n; i++)
    {
        for(int j = s; j < n; j++)
        {
            izpis[i][j] = nums[count];
            count--;
        }

        for(int j = s - 1; j >= 0; j--)
        {
            izpis[i][j] = nums[count];
            count--;
        }
    }

    for(int i = 0; i < n; i++)
    {
        for(int j = 0; j < n; j++)
        {
            printf("%d ",izpis[i][j]);
        }

        printf("\n");
    }
}