Highest score!
#9

Quote:
Originally Posted by Finn
Посмотреть сообщение
pawn Код:
static stock BubbleSort(v[], size)
{
    #if !defined swap
        #define swap(%0,%1)  (%0 ^= %1, %1 ^= %0, %0 ^= %1)
    #endif
    for(new i = 1; i != size; ++i)
    {
        for(new q = 0; (q != size - i); ++q)if(v[i] > v[q]) swap(v[q],v[i]);
    }
}

main()
{
    new Scores[] = { 10, 9, 1, 1, 1, 1, 9, 1, 1, 7, 8, 9, 10, 1, 1, 5, 1, 1, 10, 12, 1};
    BubbleSort(Scores, sizeof(Scores));
    for(new i; i < sizeof(Scores); i++)
    {
        printf("%i. %d", i, Scores[i]);
    }
}
Prints:
Код:
0. 12
1. 10
2. 10
3. 9
4. 9
5. 8
6. 7
7. 1
8. 1
9. 1
10. 1
11. 1
12. 1
13. 1
14. 1
15. 5
16. 1
17. 1
18. 9
19. 10
20. 1
oh yeah!
Fixed =).
pawn Код:
public OnFilterScriptInit()
{
    new Scores[] = { 10, 9, 1, 1, 1, 1, 9, 1, 1, 7, 8, 9, 10, 1, 1, 5, 1, 1, 10, 12, 1};
    BubbleSort(Scores, sizeof(Scores));
    for(new i; i < sizeof(Scores); i++)
    {
        printf("%i. %d", i, Scores[i]);
    }
    return true;
}

static stock BubbleSort(v[], size)
{
    #if !defined swap
        #define swap(%0,%1)   (%0 ^= %1, %1 ^= %0, %0 ^= %1)
    #endif
    for(new i = 1; i != size; ++i)
    {
        for(new q = 0; (q != size); ++q)if(v[i] > v[q]) swap(v[i],v[q]);
    }
}
Prints
Код:
[04:34:04] 0. 12
[04:34:04] 1. 10
[04:34:04] 2. 10
[04:34:04] 3. 10
[04:34:04] 4. 9
[04:34:04] 5. 9
[04:34:04] 6. 9
[04:34:04] 7. 8
[04:34:04] 8. 7
[04:34:04] 9. 5
[04:34:04] 10. 1
[04:34:04] 11. 1
[04:34:04] 12. 1
[04:34:04] 13. 1
[04:34:04] 14. 1
[04:34:04] 15. 1
[04:34:04] 16. 1
[04:34:04] 17. 1
[04:34:04] 18. 1
[04:34:04] 19. 1
[04:34:04] 20. 1
Reply


Messages In This Thread
Highest score! - by Zhoom - 03.03.2012, 04:55
Re: Highest score! - by DarkScripter - 03.03.2012, 05:13
Re: Highest score! - by Finn - 03.03.2012, 05:31
Re: Highest score! - by -Prodigy- - 03.03.2012, 05:31
Re: Highest score! - by Zhoom - 03.03.2012, 05:32
Re: Highest score! - by DarkScripter - 03.03.2012, 05:36
Re: Highest score! - by Zhoom - 03.03.2012, 05:57
Re: Highest score! - by Finn - 03.03.2012, 06:02
Re: Highest score! - by DarkScripter - 03.03.2012, 06:31

Forum Jump:


Users browsing this thread: 1 Guest(s)