1. Поиск говнокода

    Этот поиск практически ничего не может найти! Но вы всё-таки попытайтесь, вдруг повезет.

    Найдено: 35

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

    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
    26. 26
    27. 27
    #include <iostream>
    #include <functional>
    #include <array>
    
    template<typename F, int... I>
    std::array<int, sizeof...(I)> materializeImpl(const F & f, std::integer_sequence<int, I...>)
    {
        return { (f(), I)... };
    }
    
    template<size_t N, typename F, typename I = std::make_integer_sequence<int, N>>
    auto materialize(const F & f)
    {
        return materializeImpl(f, I{});
    }
    
    template<size_t N, typename F>
    void times(const F & f)
    {
        (void)materialize<N>([&f]() { f(); return 0; });
    }
    
    int main()
    {
        times<22>([]() { std::cout << "Hello There." << std::endl; });
        return EXIT_SUCCESS;
    }

    Наш инженерный отдел ебанулся на отличненько!
    https://wandbox.org/permlink/txNcEa2ZkuG2A1Sj

    gost, 19 Декабря 2019

    Комментарии (16)
  3. Си / Говнокод #25539

    +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
    #include <stdio.h>
    #include <stdlib.h>
    #include <stdint.h>
    
    int main(void)
    {
      uint32_t a = 24804541;
      for(size_t i = 0; i < 5; i++)
      {
        for(size_t j = 0; j < 5; j++)
        {
          putchar( "01"[(a >> (i*5 + j)) & 1]);
        }
        putchar('\n');
      }
      return EXIT_SUCCESS;
    }

    https://ru.wikipedia.org/wiki/Параграф_86а_Уголовного_кодекса_Германии

    > В 1998 году суд Франкфурта-на-Майне своим решением запретил распространение компьютерных игр, в которых содержится какая-либо нацистская символика — прецедентом стала игра Wolfenstein 3D. Немецкие локализаторы вынуждены были заменять в играх нацистскую символику на другие символы, не попадающие под нарушение параграфа 86а Уголовного кодекса Германии.

    Предлагаю запретить число 24804541.

    j123123, 13 Апреля 2019

    Комментарии (37)
  4. Си / Говнокод #25349

    −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
    #include <stdio.h>
    #include <stdlib.h>
    #include <inttypes.h>
    
    int main(void)
    {
      char a[8], b[8];
      char *a_ptr = a+8;
      char *b_ptr = b;
      printf("a_ptr = %p, b_ptr = %p\n", a_ptr, b_ptr);
      if (a_ptr != b_ptr)
      {
        printf("a_ptr != b_ptr\n");
      }
      else
      {
        printf("a_ptr == b_ptr\n");
      }
      
      
      if ((uintptr_t)a_ptr != (uintptr_t)b_ptr)
      {
        printf("(uintptr_t)a_ptr != (uintptr_t)b_ptr\n");
      }
      else
      {
        printf("(uintptr_t)a_ptr == (uintptr_t)b_ptr\n");
      }
      return EXIT_SUCCESS;
    }

    Что по-вашему тут происходит?

    j123123, 02 Февраля 2019

    Комментарии (39)
  5. Си / Говнокод #25013

    +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
    #include <stdio.h>
    #include <stdlib.h>
    #include <stdalign.h>
    #include <inttypes.h>
    #include <string.h>
    
    float sum_f(const float arr[], const size_t len);
    int32_t sum_i32t(const int32_t arr[], const size_t len);
    
    #define sum(a, b) _Generic((a), float*:   sum_f, \
                                 const float*:   sum_f, \
                                 int32_t*: sum_i32t,\
                                 const int32_t*: sum_i32t)(a, b)
    
    
    // foldl (+) 0 arr
    float sum_f(const float arr[], const size_t len)
    {
      return (len != 0) ? ( sum(arr+1, len-1) + arr[0] ) : 0;
    }
    
    int32_t sum_i32t(const int32_t arr[], const size_t len)
    {
      return (len != 0) ? ( sum(arr+1, len-1) + arr[0] ) : 0;
    }
    
    enum { we_want_int, we_want_float } what_we_want;
    
    void test(int www)
    {
      void *a;
      if (www == we_want_int)
      {
        uint8_t buf[sizeof(int32_t[10])] __attribute__ ((aligned (alignof(int32_t[10]))));
        a = (void *) buf;
        memcpy ( a, (int32_t[10]){1,2,3,4,5,6,7,8,9,10},
                 sizeof((int32_t[10]){1,2,3,4,5,6,7,8,9,10})
                );
        printf("%" PRIi32 "\n", sum((int32_t *)a, 10));
      }
      else if (www == we_want_float)
      {
        uint8_t buf[sizeof(float[10])] __attribute__ ((aligned (alignof(float[10]))));
        a = (void *) buf;
        memcpy ( a, (float[10]){1,2,3,4,5,6,7,8,9,10},
                 sizeof((float[10]){1,2,3,4,5,6,7,8,9,10})
                );
        printf("%f\n", sum((float *)a, 10));    
      }
    }
    
    int main(void)
    {
      test(we_want_int);
      test(we_want_float);
      return EXIT_SUCCESS;
    }

    https://wandbox.org/permlink/TwbKHE8l7ZJc6PNI
    https://govnokod.ru/25005#comment436646
    https://i.imgur.com/yFYfuED.jpg

    j123123, 23 Октября 2018

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

    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
    26. 26
    27. 27
    28. 28
    29. 29
    30. 30
    31. 31
    32. 32
    33. 33
    #include <iostream>
    #include <algorithm>
    #include <functional>
    #include <map>
    #include <string>
    
    int main()
    {
        using namespace std::placeholders;
    
        std::map<std::string, int> karta;
        std::vector<std::string> goroda{ "foo", "bar", "foo" };
    
        std::for_each(goroda.begin(), goroda.end(), std::bind(
            static_cast<
                std::pair<decltype(karta)::iterator, bool>
                (decltype(karta)::*)(const decltype(karta)::key_type&, decltype(karta)::mapped_type&&)>
                    (&decltype(karta)::insert_or_assign),
            std::ref(karta),
            _1,
            std::bind(
                std::plus<decltype(karta)::mapped_type>(),
                1,
                std::bind(
                    static_cast<decltype(karta)::mapped_type&(decltype(karta)::*)(const decltype(karta)::key_type &)>
                    (&decltype(karta)::operator[]),
                    std::ref(karta),
                    _1))
        ));
        std::cout << "foo: " << karta["foo"] << "\nbar: " << karta["bar"] << '\n';
        
        return EXIT_SUCCESS;
    }

    #24802, переписанный в функциональном modern C++ стиле.
    Переделать бы ещё это под итераторы, чтобы двух обращений к мапе не было…

    gost, 24 Сентября 2018

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

    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
    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
    #include <stdio.h>
    #include <stdlib.h>
    #include <inttypes.h>
    
    void test1(void)
    {
      printf("test1\n");
    }
    void test2(void)
    {
      printf("test2\n");
    }
    void test3(void)
    {
      printf("test3\n");
    }
    void test4(void)
    {
      printf("test4\n");
    }
    
    uint8_t func_dist[3] = {(uint8_t)((char *)test2-(char *)test1), (uint8_t)((char *)test3-(char *)test2), (uint8_t)((char *)test4-(char *)test3)};
    
    void callf(uint8_t fn)
    {
      size_t sum_dis = 0;
      for (uint8_t i = 0; i < fn; i++)
      {
        sum_dis += func_dist[i];
      }
      ( (void(*)(void)) ((char *)test1+sum_dis) )  ();
    }
    
    int main(void)
    {
      callf(0);
      callf(1);
      callf(2);
      callf(3);
      return EXIT_SUCCESS;
    }

    Зожатие указателей. Главное чтоб длины функций не превышали 255 и чтоб функции шли строго подряд, как они объявлены кода
    Как сделать чтобы это компилировалось сишкой?

    j123123, 10 Июля 2018

    Комментарии (12)
  8. Си / Говнокод #23188

    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
    26. 26
    27. 27
    28. 28
    29. 29
    30. 30
    31. 31
    32. 32
    33. 33
    34. 34
    char*a??(??)=??<
    "??=include",
    "??=include",
    "??=define o stdout",
    "??=define b break;case",
    "??=define s(p)fputs(p,o);",
    "??=define c(p)fputc(p,o);",
    "void t(p,f)char*p;????/")b'??(':s(??/"???/??/?(??/")b'??)'",
    ":s(??/"???/??/?)??/")b'??/??/??/??/':f&&s(??/"???/??/?/??/")",
    "s(??/"???/??/?/??/")b'??/??/n':if(f)s(??/"???/??/?/n??/")",
    "else case'??/"':if(f)s(??/"???/??/?/??/??/??/"??/")",
    "else default:c(*p)??>??>??>main()??;??/",0);for(p=a",
    ";*p;p++)t(*p,0);exit(!ferror(o)&&",
    "!fclose(o)?EXIT_SUCCESS",
    ":EXIT_FAILURE);",
    "/*NOTREACHED*/",
    "??>",
    0??>;
    ??=include
    ??=include
    ??=define o stdout
    ??=define b break;case
    ??=define s(p)fputs(p,o);
    ??=define c(p)fputc(p,o);
    void t(p,f)char*p;??':s("???/?>")b'??(':s("???/?(")b'??)'
    :s("???/?)")b'??/??/':f&&s("???/?/")
    s("???/?/")b'??/n':if(f)s("???/?/n")
    else case'"':if(f)s("???/?/??/"")
    else default:c(*p)??>??>??>main()??;",0);for(p=a
    ;*p;p++)t(*p,0);exit(!ferror(o)&&
    !fclose(o)?EXIT_SUCCESS
    :EXIT_FAILURE);
    /*NOTREACHED*/
    ??>

    Очередной куайн. Херня на триграфах. Взято отсюда

    http://www.nyx.net/~gthompso/self_c.txt


    Там разумеется есть намного более ебанутые варианты

    j123123, 16 Июля 2017

    Комментарии (0)
  9. bash / Говнокод #17641

    −503

    1. 1
    2. 2
    3. 3
    4. 4
    if (( $(true; echo $?) != 0 )); then
        echo >&2 "Oops, we're running on a non-existing platform."
        exit 1 # Хм, а вдруг здесь 1 == EXIT_SUCCESS?...
    fi

    (c) anonymous
    https://www.linux.org.ru/forum/development/11317153?cid=11318931

    Elvenfighter, 13 Февраля 2015

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

    +54

    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
    #include <iostream>
    #include <cstdio>
    #include <cstdlib>
    using namespace std;
     
    int main()
    {
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
        long x1, x2, x3;
        cin >> x1 >> x2 >> x3;
        if(x1 == 0 && x2 == 0 && x3 == 0){
            cout << 0 << endl;
            exit(EXIT_SUCCESS);
        }
        (x1 != 0) ? cout << x1 : cout << "";
        (x2 != 0) ? (x2 > 0 && x1 != 0) ? (x2 == 1) ? cout << "+x" : cout << '+' << x2 << 'x' : (x2 == -1) ? cout << "-x" : (x2 == 1) ? cout << 'x' : (x2 == -1) ? cout << "-x" : cout << x2 << 'x' : cout << "";
        (x3 != 0) ? (x3 == 1) ? cout << 'y' : (x3 == -1) ? cout << "-y" : (x2 == 0 && x1 == 0) ? cout << x3 << 'y' :  (x3 > 0) ? (x3 == 1) ? cout << "+y" : cout << '+' << x3 << 'y' : (x3 == -1) ? cout << "-y" : cout << x3 << 'y' : cout << "";
        cout << endl;
        return 0;
    }

    Задача № 277 на acmp.ru. Решил "не писать много кода"

    jyree, 21 Сентября 2014

    Комментарии (45)
  11. C++ / Говнокод #12815

    +3

    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
    #include <cstdlib>
    #include <iostream>
    #include <time.h>
    
    using namespace std;
    
    const int n=20;
    int mass[20];
    
    void massiv(int x[])
    {
    srand(time(NULL));
    for(int i=0;i<20;i++) mass[i]=rand()%100;
    return 0;
    }
    
    void vivod(int x[])
    {
    for(int i=0;i<20;i++) cout<<mas[i]<<"\n";
    return 0;
    }
    
    
    void sort (int x[])
    {
    int i,j,b;
    for(j=1;j<=n-1;j++)
    for(i=0;i<=n-1-j;i++)
    if (mass[i]>mass[i+1])
    {
    b=mass[i];
    mass[i]=mass[i+1];
    mass[i+1]=b;
    }
    }
    return 0;
    }
    
    int main(int argc, char *argv[])
    {
        zapolneniemassiva(mass[20]);
        pokaz(mass[20]);
    	sort(mass[20]);
    	variant3(mass[20]);
    	
        system("PAUSE");
        return EXIT_SUCCESS;
    }

    Одногруппник сделал лабу на C++, программа сортирует массив по возрастанию и выводит, ну, по крайней мере, должна.

    TBoolean, 28 Марта 2013

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