1. Список говнокодов пользователя oaoaoammm

    Всего: 4

  2. C++ / Говнокод #27123

    +2

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    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
    ShipType Ship::getShipTypeByLength(int length)
    {
        switch (length) {
            case 1: return BOAT;
            case 2: return CRUISER;
            case 3: return DESTROYER;
            case 4: return BATTLESHIP;
            case 5: return AIRCRAFT_CARRIER;
    
            default:
                std::cout << "No ship meets the given length: " << length << std::endl;
                return ERROR_SHIP;
        }
    }
    
    int Ship::getShipLengthByType(ShipType type)
    {
        switch (type) {
            case BOAT: return 1;
            case CRUISER: return 2;
            case DESTROYER: return 3;
            case BATTLESHIP: return 4;
            case AIRCRAFT_CARRIER: return 5;
    
            default:
                std::cout << "No ship meets the given type: " << type << std::endl;
                return 0;
        }
    }
    
    int Ship::getShipAmountByType(ShipType type)
    {
        switch (type) {
            case BOAT: return 4;
            case CRUISER: return 3;
            case DESTROYER: return 2;
            case BATTLESHIP: return 1;
            case AIRCRAFT_CARRIER: return 1;
    
            default:
                std::cout << "No ship meets the given type: " << type << std::endl;
                return 0;
        }
    }
    
    Coordinates Ship::getFirstBlockCoordinatesByShipData(int x, int y, int length, Orientation orientation)
    {
        Coordinates result;
        if (orientation == HORIZONTAL) {
            result.x = x - (length / 2);
            result.y = y;
        } else {
            result.x = x;
            result.y = y - (length / 2);
        }
        return result;
    }
    
    Coordinates Ship::getLastBlockCoordinatesByShipData(int x, int y, int length, Orientation orientation)
    {
        Coordinates result;
        if (orientation == HORIZONTAL) {
            result.x = x + (length / 2) + (length % 2) - 1;
            result.y = y;
        } else {
            result.x = x;
            result.y = y + (length / 2) + (length % 2) - 1;
        }
        return result;
    }

    Вот некоторые полезные функции из игры «Морской Бой», которую я зачем-то написал.

    oaoaoammm, 21 Ноября 2020

    Комментарии (44)
  3. C++ / Говнокод #27001

    0

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    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
    Node* reverse(Node* head) 
    {
    	Node *end = head, *current = head;
    	while (end->next != nullptr) {
    		end = end->next;
    	}
    	
    	Node *initial_end = end, *temp = nullptr, *temp_2 = nullptr;
    	
    	end->next = current;
    	temp = current;
    	current = current->next;
    	temp->next = nullptr;
    	
    	while (current != initial_end) {
    		
    		temp_2 = initial_end->next;
    		initial_end->next = current;
    		temp = current;
    		current = current->next;
    		temp->next = temp_2;
    	}
    	
    	return initial_end;
    }

    Я где-то прочитал, что на собесе нужно написать переворот односвязного списка за 5 минут... Спустя 2 дня получилось это.

    oaoaoammm, 04 Октября 2020

    Комментарии (8)
  4. Куча / Говнокод #26978

    −1

    1. 1
    https://foren.germany.ru/elecronics/f/20343575.html

    Математики из раш-ки изобрели бесконечные ноутбуки:

    «Если магазин предоставляет опцию возврата, если товар не понравился, то почему мне должно быть стыдно?
    Наоборот приятно - попользовался 3мя разными ноутами в течение месяца, не заплатив ни цента. Если бы им не нравилось это - они такую опцию не ввели бы, т.к. закон не обязывает.
    Я гляжу, на форуме тут мало кто знает о бесплатном 14-дневном прокате техники в Сатурне. :)»

    oaoaoammm, 25 Сентября 2020

    Комментарии (5)
  5. Assembler / Говнокод #26904

    +2

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    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
    99. 99
    lea esi, cpu_name
        mov eax, 0
        mov mreg, eax
    
        ;[04/12] G
        mov eax, 0ffh
        and eax, ebx
        mov mreg, eax
        mov al, byte ptr [mreg]
        mov [esi], al
        inc esi
    
        ;[03/12] e
        mov eax, 0ff00h
        and eax, ebx
        mov mreg, eax
        mov al, byte ptr [mreg + 1]
        mov [esi], al
        inc esi
    
        ;[02/12] n
        mov eax, 0ff0000h
        and eax, ebx
        mov mreg, eax
        mov al, byte ptr [mreg + 2]
        mov [esi], al
        inc esi
    
        ;[01/12] u
        mov eax, 0ff000000h
        and eax, ebx
        mov mreg, eax
        mov al, byte ptr [mreg + 3]
        mov [esi], al
        inc esi
    
        ;[08/12] i
        mov eax, 0ffh
        and eax, edx
        mov mreg, eax
        mov al, byte ptr [mreg]
        mov [esi], al
        inc esi
    
        ;[07/12] n
        mov eax, 0ff00h
        and eax, edx
        mov mreg, eax
        mov al, byte ptr [mreg + 1]
        mov [esi], al
        inc esi
    
        ;[06/12] e
        mov eax, 0ff0000h
        and eax, edx
        mov mreg, eax
        mov al, byte ptr [mreg + 2]
        mov [esi], al
        inc esi
    
        ;[05/12] I
        mov eax, 0ff000000h
        and eax, edx
        mov mreg, eax
        mov al, byte ptr [mreg + 3]
        mov [esi], al
        inc esi
    
        ;[12/12] n
        mov eax, 0ffh
        and eax, ecx
        mov mreg, eax
        mov al, byte ptr [mreg]
        mov [esi], al
        inc esi
    
        ;[11/12] t
        mov eax, 0ff00h
        and eax, ecx
        mov mreg, eax
        mov al, byte ptr [mreg + 1]
        mov [esi], al
        inc esi
    
        ;[10/12] e
        mov eax, 0ff0000h
        and eax, ecx
        mov mreg, eax
        mov al, byte ptr [mreg + 2]
        mov [esi], al
        inc esi
    
        ;[09/12] l
        mov eax, 0ff000000h
        and eax, ecx
        mov mreg, eax
        mov al, byte ptr [mreg + 3]
        mov [esi], al
        inc esi

    oaoaoammm, 01 Сентября 2020

    Комментарии (224)