Keresés

Aktív témák

  • Joooe

    tag

    válasz andorpapa #16 üzenetére

    nem éppen optimális megoldás, de most ennyire fussa :)

    #include <stdio.h>

    int screen[80][25];

    int EloSzomszedok(int x, int y)
    {
    int dy,dx;
    int szum=0;

    for (dy=-1; dy<=1; dy++)
    for (dx=-1; dx<=1; dx++)
    {
    if ( (dx==0 && dy==0) || (x+dx<0) || (x+dx>=80) || (y+dy<0) || (y+dy>=25)) continue;
    szum+=screen[x+dx][y+dy];
    }
    return szum;
    }

    int main()
    {



    int screen2[80][25];
    int esz;

    int x,y,szsz;

    for (y=0; y<=24; ++y)
    for (x=0; x<=79; ++x)
    screen[x][y]=0;

    for (y=10; y<=12; ++y)
    for (x=39; x<=41; ++x)
    screen [x][y]=1;


    while (true)
    {
    for (y=0;y<=24;++y)
    {
    for (x=0;x<=79;++x)
    if (screen[x][y]) printf(''x'');
    else printf(''-'');
    }



    for (y=0;y<=24;++y)
    for (x=0;x<=79;++x)
    {
    esz=EloSzomszedok(x,y);
    if (screen[x][y])
    {
    if (!(esz==2 || esz==3)) screen2[x][y]=0;
    else screen2[x][y]=1;
    }
    else
    {
    if (esz==3) screen2[x][y]=1;
    else screen2[x][y]=0;
    }
    }

    for (y=0;y<=24;++y)
    for (x=0;x<=79;++x)
    screen[x][y]=screen2[x][y];

    // ide kéne valami várakoztatás
    }



    }

    Hogy mit gondolok a nyugati civilizációról? Azt hiszem, jó ötlet lenne.

Aktív témák