Rezultati

Up. imeNalogaJezikRezultatČas oddaje
lml-2018 Plezalne smeri C++ 100/100OK 13. okt '18 @ 13:12

Test Točke Porabljen spomin Porabljen čas Status
#1 50/50 2,895 MiB 0,004 s OK
#2 50/50 2,895 MiB 0,000 s OK

Ocenjevani program (Smeri.cpp):
#include <stdio.h>
#include <map>
#include <string>
#include <string.h>
#include <algorithm>

using namespace std;


class Name
{
    public:
        char name[101];
        int value;
        Name(char* name, int value);
        Name();
};

Name::Name()
{

}

Name::Name(char* name,int value)
{
    strcpy(this->name,name);
    this->value = value;
}

int compare(const void* p1, const void* p2)
{
    Name* point1 = (Name*)(p1);
    Name* point2 = (Name*)(p2);

    if(point1->value == point2->value)
        return strcmp(point1->name,point2->name);

    return point1->value - point2->value;
}

int main()
{
    map<string,int> m;
    m["I"] = 3;
    m["II"] = 6;
    m["III"] = 9;
    m["IV"] = 12;
    m["V"] = 15;
    m["VI"] = 18;
    m["VII"] = 21;
    m["VIII"] = 24;
    m["IX"] = 27;
    m["X"] = 30;
    m["XI"] = 33;
    m["XII"] = 36;
    m["I-"] = 2;
    m["II-"] = 5;
    m["III-"] = 8;
    m["IV-"] = 11;
    m["V-"] = 14;
    m["VI-"] = 17;
    m["VII-"] = 20;
    m["VIII-"] = 23;
    m["IX-"] = 26;
    m["X-"] = 29;
    m["XI-"] = 32;
    m["XII-"] = 35;
    m["I+"] = 4;
    m["II+"] = 7;
    m["III+"] = 10;
    m["IV+"] = 13;
    m["V+"] = 16;
    m["VI+"] = 19;
    m["VII+"] = 22;
    m["VIII+"] = 25;
    m["IX+"] = 28;
    m["X+"] = 31;
    m["XI+"] = 34;
    m["XII+"] = 37;
    int n;
    Name array[120];

    scanf("%d",&n);

    for(int i = 0; i < n; i++)
    {
        char s[101];
        char num[101];
        scanf("%s %s",s,num);
        string v = num;
        Name name(s,m[v]);
        array[i] = name;
    }

    qsort(array,n,sizeof(Name),compare);

    for(int i = 0; i < n; i++)
    {
        printf("%s\n",array[i].name);
    }
}