1. Си / Говнокод #25526

    +1

    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
    #include <stdio.h>
    #include <stdlib.h>
    
    void myfree(void *ptr)
    {
      printf("%p\n", *(void **)ptr);
      free(*(void **)ptr);
      printf("freed!\n");
    }
    
    int main(void) {
      char *x __attribute__ (( cleanup (myfree)  )) = malloc(1);
      printf("%p\n", x);
      return 0;
    }

    https://gcc.gnu.org/onlinedocs/gcc/Common-Variable-Attributes.html

    cleanup (cleanup_function)

    The cleanup attribute runs a function when the variable goes out of scope. This attribute can only be applied to auto function scope variables; it may not be applied to parameters or variables with static storage duration. The function must take one parameter, a pointer to a type compatible with the variable. The return value of the function (if any) is ignored.

    If -fexceptions is enabled, then cleanup_function is run during the stack unwinding that happens during the processing of the exception. Note that the cleanup attribute does not allow the exception to be caught, only to perform an action. It is undefined what happens if cleanup_function does not return normally.

    j123123, 09 Апреля 2019

    Комментарии (28)
  2. Куча / Говнокод #25525

    −106

    1. 1
    Вы все дураки и не лечитесь

    HEPEALHO_KPYT, 09 Апреля 2019

    Комментарии (0)
  3. Python / Говнокод #25524

    +1

    1. 1
    2. 2
    3. 3
    4. 4
    for i in for i in itertools.count():
        # ...
        if i >= x:
            break

    syoma, 08 Апреля 2019

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

    −101

    1. 1
    Забаньте гостинхо.

    Гуестинхо

    fuckyou, 08 Апреля 2019

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

    0

    1. 1
    if (true === false)

    не ну шоб наверняка

    quentiam, 08 Апреля 2019

    Комментарии (10)
  6. C# / Говнокод #25521

    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
    using System;
    using System.Linq;
    using s = System.String;
    using i = System.Int32;
    class Player
    {
        static i sgn(i x) => x < 0 ? -1 : x > 0 ? 1 : 0;
        static s g(ref i z, i Z, s S)
        {
            i t = sgn(z - Z);
            if (t < 0) z++;
            else if (t > 0) z--;
            return S[t + 1] + "";
        }
        static void Main()
        {
            var a = Console.ReadLine().Split().Select(i.Parse).ToArray();
            i X = a[0], Y = a[1], x = a[2], y = a[3];
            while (true)
            {
                Console.ReadLine();
                Console.WriteLine(g(ref y, Y, "S N") + g(ref x, X, "E W"));
            }
        }
    }

    Поиск пути на плоскости от первой точки координат до второй. Выводит направление следующего передвижения.

    groser, 08 Апреля 2019

    Комментарии (42)
  7. C++ / Говнокод #25520

    +1

    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
    #include <iostream>
    #include <functional>
    #include <array>
    #include <iterator>
    
    template <class T>
    class Filter : public std::iterator<
                     std::input_iterator_tag,
                     typename std::iterator_traits<T>::value_type,
                     typename std::iterator_traits<T>::difference_type,
                     typename std::iterator_traits<T>::pointer,
                     typename std::iterator_traits<T>::reference
                   >
    {
    private:
      typedef typename std::iterator_traits<T>::value_type value_type;
      std::function<bool(value_type)> m_predicate;
      T m_begin, m_end;
      value_type m_current;
    
    public:
      Filter(T t_begin, T t_end, std::function<bool(value_type)> t_predicate)
        : m_begin(t_begin), m_end(t_end), m_predicate(t_predicate)
      {
      }
      
      Filter<T>& begin()
      {
        return ++*this;
      }
      
      Filter<T>& end()
      {
        return *this;
      }
      
      value_type operator* ()
      {
        return m_current;
      }
      
      Filter<T>& operator++ ()
      {
        do {
          m_current = *m_begin;
          ++m_begin;
        } while (m_begin != m_end && !m_predicate(m_current));
        return *this;
      }
      
      
      bool operator!= (Filter<T>& t_right)
      {
        return m_begin != t_right.m_end;
      }
    };
    
    
    int main()
    {
      std::array<int, 10> arr{ {4, 35, 0, 23, 0, 0, 5} };
      for (auto i : Filter<typename std::array<int,10>::iterator>(arr.begin(), arr.end(), [](int x){return x != 0;})) {
        std::cout << i << " ";
      }
    }

    Lemming, 07 Апреля 2019

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

    −99

    1. 1
    Прошу забанить всех на один год.

    админа - бессрочно.

    AHCKujlbHblu_netyx, 06 Апреля 2019

    Комментарии (52)
  9. Куча / Говнокод #25518

    +2

    1. 1
    https://i.yapx.ru/D3IPu.jpg

    Как я вам?)

    zheurova_elya, 06 Апреля 2019

    Комментарии (27)
  10. JavaScript / Говнокод #25517

    −1

    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
    function isSpam(comment) {
        // quick and dirty filter agains guest spam
        // it can reject normal links, but who cares...
        if ((comment.user_id == 1) && comment.text.match('http://'))
                return true;
    
        if ((comment.user_id == 25580) && ((comment.text.match('^, http')) ||
                                           (comment.text.match(',  , http')) ||
                                           (comment.text.match('&lt;strong&gt;')) ||
                                           (comment.text.match('^&lt;a href=')) ||
                                           (comment.text.match('^comment[0-9]+,')) ||
                                           (comment.text.match('storefocus')) ||
                                           (comment.text.match('.*Хрюкни, свинособака')) ||
                                           (comment.text.match('.*<span style')) ||
                                           (comment.text.replace(/\s*/g, '').match('viagra|cialis|levitra')) ||
                                           (comment.text.match('-[0-9a-fA-F]{4}\.pdf'))))
                return true;
        return false;
    }

    http://gcode.cx/ngk/#!/settings

    Какой анскилл )))

    OCETuHCKuu_nemyx, 06 Апреля 2019

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