Няшная / Говнокод #29279 Ссылка на оригинал

0

  1. 1
  2. 2
  3. 3
  4. 4
  5. 5
  6. 6
  7. 7
  8. 8
  9. 9
  10. 10
  11. 11
  12. 12
  13. 13
  14. 14
  15. 15
  16. 16
  17. 17
  18. 18
  19. 19
  20. 20
  21. 21
  22. 22
  23. 23
  24. 24
  25. 25
  26. 26
  27. 27
  28. 28
  29. 29
  30. 30
  31. 31
  32. 32
  33. 33
  34. 34
  35. 35
  36. 36
  37. 37
  38. 38
  39. 39
  40. 40
  41. 41
  42. 42
  43. 43
  44. 44
  45. 45
  46. 46
  47. 47
  48. 48
  49. 49
  50. 50
  51. 51
  52. 52
  53. 53
  54. 54
  55. 55
  56. 56
  57. 57
  58. 58
  59. 59
  60. 60
  61. 61
  62. 62
  63. 63
  64. 64
  65. 65
  66. 66
  67. 67
  68. 68
  69. 69
  70. 70
  71. 71
  72. 72
  73. 73
  74. 74
  75. 75
  76. 76
  77. 77
  78. 78
  79. 79
  80. 80
  81. 81
  82. 82
  83. 83
  84. 84
  85. 85
  86. 86
  87. 87
  88. 88
  89. 89
  90. 90
  91. 91
  92. 92
  93. 93
  94. 94
  95. 95
  96. 96
  97. 97
  98. 98
#include <stdio.h>

typedef struct true_t {
    char _;
} true_t;

true_t TRUE;

typedef struct false_t {
    char _;
} false_t;

false_t FALSE;

int f_true() {
    return 1;
}

int f_false() {
    return 0;
}

#define bool_v(B) _Generic((B *) (0), true_t *: TRUE, false_t *: FALSE)
#define bool_v_to_int(B) _Generic(B, true_t: 1, false_t: 0)

#define v_to_bool(V) typeof(V)

#define is_string_v(X) _Generic((X), \
        char *: 1,                   \
        default: 0)

#define is_string_t(X) typeof(_Generic((X), \
        char *: TRUE,                       \
        default: FALSE))


#define has_signature_v(X, R, ...)         \
    _Generic((X),                          \
            SignatureM(R, __VA_ARGS__): 1, \
            default: 0)

#define has_signature_t(X, R, ...)            \
    typeof(_Generic((X),                      \
            SignatureM(R, __VA_ARGS__): TRUE, \
            default: FALSE))

#define to_string(x) _Generic((x), \
        true_t: "true",            \
        false_t: "false",          \
        char*: x,                  \
        const char*: x)

#define has_same_type_v(X, Y)       \
    _Generic(has_same_type_t(X, Y), \
            true_t: 1,              \
            false_t: 0)

#define has_same_type_t(X, Y) typeof(_Generic((X), \
        typeof(Y): TRUE,                           \
        default: FALSE))

#define SignatureM(R, ...) R (*)(__VA_ARGS__)

#define is_same_t(X, Y)          \
    typeof(_Generic(((X *) (0)), \
            Y *: TRUE,           \
            default: FALSE))

#define and_t(X, Y)                                                    \
    typeof(_Generic(bool_v(X),                                         \
            true_t: _Generic(bool_v(Y), true_t: TRUE, false_t: FALSE), \
            false_t: _Generic(bool_v(Y), true_t: FALSE, false_t: FALSE)))

#define or_t(X, Y)                                                    \
    typeof(_Generic(bool_v(X),                                        \
            true_t: _Generic(bool_v(Y), true_t: TRUE, false_t: TRUE), \
            false_t: _Generic(bool_v(Y), true_t: TRUE, false_t: FALSE)))

#define not_t(X)               \
    typeof(_Generic(bool_v(X), \
            true_t: FALSE,     \
            false_t: TRUE))

#define result_t(X, ...) typeof((X) (__VA_ARGS__))

#define id_sig(T) SignatureM(T, void)
#define true_sig id_sig(true_t)
#define false_sig id_sig(false_t)
#define _0 false_sig
#define _1 true_sig

#define bool_sig_v(S) _Generic((S) (0), true_sig: TRUE, false_sig: FALSE)
#define bool_sig_int(S) _Generic((S) (0), true_sig: 1, false_sig: 0)
#define bool_sig_t(S) typeof(bool_sig_v(S))

#define sig_apply_res_t(X) typeof(((X) (0))())

#define is_same_sig_t(SA, SB) typeof(_Generic((SA) (0), SB: TRUE, default: FALSE))

j123123 j123123, (Updated )

Комментарии (4, +4)

Няшная / Говнокод #29278 Ссылка на оригинал

0

  1. 1
  2. 2
  3. 3
  4. 4
  5. 5
  6. 6
  7. 7
  8. 8
  9. 9
  10. 10
  11. 11
  12. 12
  13. 13
  14. 14
  15. 15
  16. 16
  17. 17
  18. 18
  19. 19
  20. 20
  21. 21
  22. 22
  23. 23
  24. 24
  25. 25
  26. 26
  27. 27
  28. 28
  29. 29
  30. 30
  31. 31
  32. 32
  33. 33
  34. 34
  35. 35
  36. 36
  37. 37
  38. 38
  39. 39
  40. 40
  41. 41
  42. 42
  43. 43
  44. 44
  45. 45
  46. 46
  47. 47
  48. 48
  49. 49
  50. 50
  51. 51
  52. 52
  53. 53
  54. 54
  55. 55
  56. 56
  57. 57
  58. 58
  59. 59
  60. 60
  61. 61
  62. 62
  63. 63
  64. 64
  65. 65
// Глобальные переменные

uint8_t *map = NULL;
int map_width = 0;
int map_height = 0;

bool load_level(const char *filename) {
    FILE *file = fopen(filename, "r");
    if (!file) {
        printf("Ошибка: Не удалось открыть файл %s\n", filename);
        return false;
    }

    char lines[512][512];
    int h = 0;
    char buffer[512];

    while (fgets(buffer, sizeof(buffer), file)) {
        buffer[strcspn(buffer, "\r\n")] = 0;
        if (buffer[0] == '\0' || buffer[0] == ';') continue;

        bool contains_map_char = false;
        for(int i=0; buffer[i]; i++) {
            if (strchr("#$@.*+ ", buffer[i])) {
                contains_map_char = true;
                break;
            }
        }
        
        if (contains_map_char) {
            strncpy(lines[h], buffer, 511);
            h++;
            if (h >= 512) break;
        }
        if (h > 0 && buffer[0] == '\0') break;
    }
    fclose(file);

    if (h == 0) return false;

    int w = 0;
    for (int i = 0; i < h; i++) {
        int len = strlen(lines[i]);
        if (len > w) w = len;
    }

    map = malloc(w * h * sizeof(uint8_t));
    map_width = w;
    map_height = h;
    memset(map, CELL_EMPTY, w * h);

    for (int y = 0; y < h; y++) {
        for (int x = 0; x < w; x++) {
            char c = (x < (int)strlen(lines[y])) ? lines[y][x] : ' ';
            if (c == '#') map[y * w + x] = CELL_WALL;
            else if (c == '$') map[y * w + x] = CELL_CUBE;
            else if (c == '.') map[y * w + x] = CELL_TARGET;
            else if (c == '*') map[y * w + x] = CELL_CUBE_ON_TARGET;
            else if (c == '@') { map[y * w + x] = CELL_EMPTY; playerX = x; playerY = y; }
            else if (c == '+') { map[y * w + x] = CELL_TARGET; playerX = x; playerY = y; }
            else map[y * w + x] = CELL_EMPTY;
        }
    }
    return true;
}

Загружалка уровня сокобана, сгенерированная нейронкой

j123123 j123123, (Updated )

Комментарии (11, +11)

Куча говна / Говнокод #29277 Ссылка на оригинал

0

  1. 1
Пиздец-оффтоп #132

#102: https://govnokod.ru/28978 https://govnokod.xyz/_28978
#103: https://govnokod.ru/28982 https://govnokod.xyz/_28982
#104: https://govnokod.ru/28989 https://govnokod.xyz/_28989
#105: https://govnokod.ru/29052 https://govnokod.xyz/_29052
#106: https://govnokod.ru/29069 https://govnokod.xyz/_29069
#107: (vanished) https://govnokod.xyz/_29086
#108: https://govnokod.ru/29102 https://govnokod.xyz/_29102
#109: https://govnokod.ru/29126 https://govnokod.xyz/_29126
#110: https://govnokod.ru/29136 https://govnokod.xyz/_29136
#111: https://govnokod.ru/29142 https://govnokod.xyz/_29142
#112: https://govnokod.ru/29155 https://govnokod.xyz/_29155
#113: https://govnokod.ru/29160 https://govnokod.xyz/_29160
#114: https://govnokod.ru/29165 https://govnokod.xyz/_29165
#115: https://govnokod.ru/29173 https://govnokod.xyz/_29173
#116: https://govnokod.ru/29174 https://govnokod.xyz/_29174
#117: https://govnokod.ru/29182 https://govnokod.xyz/_29182
#118: https://govnokod.ru/29191 https://govnokod.xyz/_29191
#119: https://govnokod.ru/29196 https://govnokod.xyz/_29196
#120: https://govnokod.ru/29205 https://govnokod.xyz/_29205
#121: https://govnokod.ru/29216 https://govnokod.xyz/_29216
#122: https://govnokod.ru/29219 https://govnokod.xyz/_29219
#123: https://govnokod.ru/29232 https://govnokod.xyz/_29232
#124: https://govnokod.ru/29237 https://govnokod.xyz/_29237
#125: https://govnokod.ru/29239 https://govnokod.xyz/_29239
#126: https://govnokod.ru/29244 https://govnokod.xyz/_29244
#127: https://govnokod.ru/29248 https://govnokod.xyz/_29248
#128: https://govnokod.ru/29251 https://govnokod.xyz/_29251
#129: https://govnokod.ru/29257 https://govnokod.xyz/_29257
#130: https://govnokod.ru/29266 https://govnokod.xyz/_29266
#131: https://govnokod.ru/29270 https://govnokod.xyz/_29270

nepeKamHblu_nemyx nepeKamHblu_nemyx, (Updated )

Комментарии (335, +335)

Куча говна / Говнокод #29275 Ссылка на оригинал

0

  1. 1
Бесконечный оффтоп имени Гологуба #11

#1: https://govnokod.ru/28992 https://govnokod.xyz/_28992
#2: https://govnokod.ru/29053 https://govnokod.xyz/_29053
#3: https://govnokod.ru/29075 https://govnokod.xyz/_29075
#4: https://govnokod.ru/29110 https://govnokod.xyz/_29110
#5: https://govnokod.ru/29127 https://govnokod.xyz/_29127
#6: https://govnokod.ru/29140 https://govnokod.xyz/_29140
#7: https://govnokod.ru/29170 https://govnokod.xyz/_29170
#8: https://govnokod.ru/29192 https://govnokod.xyz/_29192
#9: https://govnokod.ru/29227 https://govnokod.xyz/_29227
#10: https://govnokod.ru/29258 https://govnokod.xyz/_29258

nepeKamHblu_nemyx nepeKamHblu_nemyx, (Updated )

Комментарии (146, +146)

Куча говна / Говнокод #29274 Ссылка на оригинал

0

  1. 1
IT Оффтоп #238

#208: https://govnokod.ru/29060 https://govnokod.xyz/_29060
#209: https://govnokod.ru/29070 https://govnokod.xyz/_29070
#210: https://govnokod.ru/29079 https://govnokod.xyz/_29079
#211: https://govnokod.ru/29092 https://govnokod.xyz/_29092
#212: https://govnokod.ru/29093 https://govnokod.xyz/_29093
#213: https://govnokod.ru/29104 https://govnokod.xyz/_29104
#214: https://govnokod.ru/29114 https://govnokod.xyz/_29114
#215: https://govnokod.ru/29125 https://govnokod.xyz/_29125
#216: https://govnokod.ru/29132 https://govnokod.xyz/_29132
#217: https://govnokod.ru/29147 https://govnokod.xyz/_29147
#218: https://govnokod.ru/29156 https://govnokod.xyz/_29156
#219: https://govnokod.ru/29166 https://govnokod.xyz/_29166
#220: https://govnokod.ru/29181 https://govnokod.xyz/_29181
#221: https://govnokod.ru/29185 https://govnokod.xyz/_29185
#222: https://govnokod.ru/29190 https://govnokod.xyz/_29190
#223: https://govnokod.ru/29203 https://govnokod.xyz/_29203
#224: https://govnokod.ru/29211 https://govnokod.xyz/_29211
#225: https://govnokod.ru/29212 https://govnokod.xyz/_29212
#226: https://govnokod.ru/29218 https://govnokod.xyz/_29218
#227: https://govnokod.ru/29220 https://govnokod.xyz/_29220
#228: https://govnokod.ru/29230 https://govnokod.xyz/_29230
#229: https://govnokod.ru/29235 https://govnokod.xyz/_29235
#230: https://govnokod.ru/29241 https://govnokod.xyz/_29241
#231: https://govnokod.ru/29246 https://govnokod.xyz/_29246
#232: https://govnokod.ru/29249 https://govnokod.xyz/_29249
#233: https://govnokod.ru/29253 https://govnokod.xyz/_29253
#234: https://govnokod.ru/29259 https://govnokod.xyz/_29259
#235: https://govnokod.ru/29262 https://govnokod.xyz/_29262
#236: https://govnokod.ru/29267 https://govnokod.xyz/_29267
#237: https://govnokod.ru/29271 https://govnokod.xyz/_29271

nepeKamHblu_nemyx nepeKamHblu_nemyx, (Updated )

Комментарии (290, +290)

Си диез / Говнокод #29272 Ссылка на оригинал

0

  1. 1
  2. 2
  3. 3
  4. 4
  5. 5
  6. 6
  7. 7
Console.WriteLine("хуй");
string? input = Console.ReadLine();
Console.ReadLine();
if (Console.ReadLine() == "иди нахуй");
{
    Console.WriteLine("сам");
}

Нужно написать в консоль 3 раза чтобы получить ответ

CJNG CJNG, (Updated )

Комментарии (26, +26)

Куча говна / Говнокод #29271 Ссылка на оригинал

0

  1. 1
IT Оффтоп #237

#207: https://govnokod.ru/29002 https://govnokod.xyz/_29002
#208: https://govnokod.ru/29060 https://govnokod.xyz/_29060
#209: https://govnokod.ru/29070 https://govnokod.xyz/_29070
#210: https://govnokod.ru/29079 https://govnokod.xyz/_29079
#211: https://govnokod.ru/29092 https://govnokod.xyz/_29092
#212: https://govnokod.ru/29093 https://govnokod.xyz/_29093
#213: https://govnokod.ru/29104 https://govnokod.xyz/_29104
#214: https://govnokod.ru/29114 https://govnokod.xyz/_29114
#215: https://govnokod.ru/29125 https://govnokod.xyz/_29125
#216: https://govnokod.ru/29132 https://govnokod.xyz/_29132
#217: https://govnokod.ru/29147 https://govnokod.xyz/_29147
#218: https://govnokod.ru/29156 https://govnokod.xyz/_29156
#219: https://govnokod.ru/29166 https://govnokod.xyz/_29166
#220: https://govnokod.ru/29181 https://govnokod.xyz/_29181
#221: https://govnokod.ru/29185 https://govnokod.xyz/_29185
#222: https://govnokod.ru/29190 https://govnokod.xyz/_29190
#223: https://govnokod.ru/29203 https://govnokod.xyz/_29203
#224: https://govnokod.ru/29211 https://govnokod.xyz/_29211
#225: https://govnokod.ru/29212 https://govnokod.xyz/_29212
#226: https://govnokod.ru/29218 https://govnokod.xyz/_29218
#227: https://govnokod.ru/29220 https://govnokod.xyz/_29220
#228: https://govnokod.ru/29230 https://govnokod.xyz/_29230
#229: https://govnokod.ru/29235 https://govnokod.xyz/_29235
#230: https://govnokod.ru/29241 https://govnokod.xyz/_29241
#231: https://govnokod.ru/29246 https://govnokod.xyz/_29246
#232: https://govnokod.ru/29249 https://govnokod.xyz/_29249
#233: https://govnokod.ru/29253 https://govnokod.xyz/_29253
#234: https://govnokod.ru/29259 https://govnokod.xyz/_29259
#235: https://govnokod.ru/29262 https://govnokod.xyz/_29262
#236: https://govnokod.ru/29267 https://govnokod.xyz/_29267

nepeKamHblu_nemyx nepeKamHblu_nemyx, (Updated )

Комментарии (450, +450)

Куча говна / Говнокод #29270 Ссылка на оригинал

0

  1. 1
Пиздец-оффтоп #131

#101: https://govnokod.ru/28949 https://govnokod.xyz/_28949
#102: https://govnokod.ru/28978 https://govnokod.xyz/_28978
#103: https://govnokod.ru/28982 https://govnokod.xyz/_28982
#104: https://govnokod.ru/28989 https://govnokod.xyz/_28989
#105: https://govnokod.ru/29052 https://govnokod.xyz/_29052
#106: https://govnokod.ru/29069 https://govnokod.xyz/_29069
#107: (vanished) https://govnokod.xyz/_29086
#108: https://govnokod.ru/29102 https://govnokod.xyz/_29102
#109: https://govnokod.ru/29126 https://govnokod.xyz/_29126
#110: https://govnokod.ru/29136 https://govnokod.xyz/_29136
#111: https://govnokod.ru/29142 https://govnokod.xyz/_29142
#112: https://govnokod.ru/29155 https://govnokod.xyz/_29155
#113: https://govnokod.ru/29160 https://govnokod.xyz/_29160
#114: https://govnokod.ru/29165 https://govnokod.xyz/_29165
#115: https://govnokod.ru/29173 https://govnokod.xyz/_29173
#116: https://govnokod.ru/29174 https://govnokod.xyz/_29174
#117: https://govnokod.ru/29182 https://govnokod.xyz/_29182
#118: https://govnokod.ru/29191 https://govnokod.xyz/_29191
#119: https://govnokod.ru/29196 https://govnokod.xyz/_29196
#120: https://govnokod.ru/29205 https://govnokod.xyz/_29205
#121: https://govnokod.ru/29216 https://govnokod.xyz/_29216
#122: https://govnokod.ru/29219 https://govnokod.xyz/_29219
#123: https://govnokod.ru/29232 https://govnokod.xyz/_29232
#124: https://govnokod.ru/29237 https://govnokod.xyz/_29237
#125: https://govnokod.ru/29239 https://govnokod.xyz/_29239
#126: https://govnokod.ru/29244 https://govnokod.xyz/_29244
#127: https://govnokod.ru/29248 https://govnokod.xyz/_29248
#128: https://govnokod.ru/29251 https://govnokod.xyz/_29251
#129: https://govnokod.ru/29257 https://govnokod.xyz/_29257
#130: https://govnokod.ru/29266 https://govnokod.xyz/_29266

nepeKamHblu_nemyx nepeKamHblu_nemyx, (Updated )

Комментарии (409, +409)