1. Лучший говнокод

    В номинации:
    За время:
  2. Си / Говнокод #4018

    +135

    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>
     
    int main()
    {
       static int val = 1;
       while(val /* vanish */ --> 0)
       {
          (++ /* do black magic ! */  val) /* very black magic !!! */ ++;
          (val == 2 ? printf("WTF ??!") : val =- 1);
       }
     
       if(val<-15)
               return ((1<0?/* magic */100500:500?233?33?321?2223?0:0:0:0:0:0));
     
       return ((!!val==!!false)?val ==- 100500?5:1:main());
    }

    Из разряда синтаксиса языка

    ForEveR, 17 Августа 2010

    Комментарии (74)
  3. Куча / Говнокод #29245

    0

    1. 1
    Питушня #43

    #13: https://govnokod.ru/27260 https://govnokod.xyz/_27260
    #14: https://govnokod.ru/27343 https://govnokod.xyz/_27343
    #15: https://govnokod.ru/27353 https://govnokod.xyz/_27353
    #16: https://govnokod.ru/27384 https://govnokod.xyz/_27384
    #17: https://govnokod.ru/27482 https://govnokod.xyz/_27482
    #18: https://govnokod.ru/27514 https://govnokod.xyz/_27514
    #19: https://govnokod.ru/27620 https://govnokod.xyz/_27620
    #20: https://govnokod.ru/27816 https://govnokod.xyz/_27816
    #21: https://govnokod.ru/27956 https://govnokod.xyz/_27956
    #22: https://govnokod.ru/28143 https://govnokod.xyz/_28143
    #23: https://govnokod.ru/28315 https://govnokod.xyz/_28315
    #24: (vanished) https://govnokod.xyz/_28362
    #25: (vanished) https://govnokod.xyz/_28463
    #26: https://govnokod.ru/28481 https://govnokod.xyz/_28481
    #27: https://govnokod.ru/28537 https://govnokod.xyz/_28537
    #28: https://govnokod.ru/28619 https://govnokod.xyz/_28619
    #29: (vanished) https://govnokod.xyz/_28663
    #30: https://govnokod.ru/28673 https://govnokod.xyz/_28673
    #31: https://govnokod.ru/28679 https://govnokod.xyz/_28679
    #32: https://govnokod.ru/28687 https://govnokod.xyz/_28687
    #33: https://govnokod.ru/28694 https://govnokod.xyz/_28694
    #34: https://govnokod.ru/28701 https://govnokod.xyz/_28701
    #35: https://govnokod.ru/28707 https://govnokod.xyz/_28707
    #36: https://govnokod.ru/28714 https://govnokod.xyz/_28714
    #37: https://govnokod.ru/28724 https://govnokod.xyz/_28724
    #38: https://govnokod.ru/28732 https://govnokod.xyz/_28732
    #39: https://govnokod.ru/28839 https://govnokod.xyz/_28839
    #40: https://govnokod.ru/28909 https://govnokod.xyz/_28909
    #41: https://govnokod.ru/29003 https://govnokod.xyz/_29003
    #42: https://govnokod.ru/29186 https://govnokod.xyz/_29186

    nepeKamHblu_nemyx, 31 Марта 2026

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

    +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
    union bitdata {
        struct {
          unsigned int bit1 : 1;
          unsigned int bit2 : 1;
          unsigned int bit3 : 1;
          unsigned int bit4 : 1;
          unsigned int bit5 : 1;
          unsigned int bit6 : 1;
          unsigned int bit7 : 1;
          unsigned int bit8 : 1;
        };
        unsigned char byte;
      } first_byte, second_byte;
    
    <...>
    
    for ( j = 0; j < bytes_count; j++ ) {
          unsigned char t;
    
          ret = gzread( gz_fd, &t, sizeof( t ) );
          if ( ret != sizeof( t ) ) {
        printf( "Failed to read file %s: %s\n", argv[i], strerror( errno ) );
        gzclose( gz_fd );
        return EXIT_FAILURE;
          }
    
          first_byte.byte  = t;
          second_byte.byte = ready_bytes[j];
    
          first_byte.bit1 = first_byte.bit1 == 0 && second_byte.bit1 == 0 ? 0 : 1;
          first_byte.bit2 = first_byte.bit2 == 0 && second_byte.bit2 == 0 ? 0 : 1;
          first_byte.bit3 = first_byte.bit3 == 0 && second_byte.bit3 == 0 ? 0 : 1;
          first_byte.bit4 = first_byte.bit4 == 0 && second_byte.bit4 == 0 ? 0 : 1;
          first_byte.bit5 = first_byte.bit5 == 0 && second_byte.bit5 == 0 ? 0 : 1;
          first_byte.bit6 = first_byte.bit6 == 0 && second_byte.bit6 == 0 ? 0 : 1;
          first_byte.bit7 = first_byte.bit7 == 0 && second_byte.bit7 == 0 ? 0 : 1;
          first_byte.bit8 = first_byte.bit8 == 0 && second_byte.bit8 == 0 ? 0 : 1;
    
          ready_bytes[j] = first_byte.byte;
        }

    Всё еще не можем понять, зачем в конце тернарник. Всё остальное уже не смущает.

    codemeow, 21 Января 2022

    Комментарии (73)
  5. C++ / Говнокод #27768

    0

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    8. 8
    auto DivisibleBy = [](int d)
        {
            return [d](int m) { return m % d == 0; };
        };
     
        if (ranges::any_of(v, DivisibleBy(7))) {
            std::cout << "At least one number is divisible by 7\n";
        }

    https://en.cppreference.com/w/cpp/algorithm/ranges/all_any_none_of

    digitalEugene, 26 Октября 2021

    Комментарии (73)
  6. JavaScript / Говнокод #27341

    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
    function isNumeric(str)      //for non-numeric fields
    {
    	var FlagS=0, FlagN=0;
    	var str1=new Array();
    	
    	for(var i=0;i<str.length;i++) //convert string to a char array
    	{
    		str1[i]=str.charAt(i);
    	}	
    	for(i=0;i<str1.length;i++)   //check for digits
    	{
    		if(str1[i]>='0'&&str1[i]<='9' ) 
    		{
    			FlagN=1;
    		}
    	}
    	if(FlagS==1||FlagN==1) 		//give a final decision
    	{ 
    		FlagS=FlagN=0;
    		return true;
    	}
    }

    Красота по-индийски. FlagS не понадобился, ну и хер с ним :)

    kropotor, 08 Апреля 2021

    Комментарии (73)
  7. PHP / Говнокод #27337

    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
    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
    public function addMoney($name, $amount, $type)
    	{
    		$checkExist = $this->checkUserMoney($name);
    		$checkExist = ($checkExist != '<b>(Ico)</b> <h11 style=\"color: red\">Произошла ошибка!</h11> <br/>') ? true : false;
    		$name_uuid = $this->genUUID($name);
    		
    		if ($this->version == '1.12.2' AND $this->plugin != 'iconomy')
    		{
    			if ($checkExist)
    			{
    				if ($type == 'add')
    				{
    					$queryText = ($this->plugin == 'economylite') ? "UPDATE `economyliteplayers` SET `balance` = `balance` + '$amount' WHERE `uuid` = '$name_uuid' AND `currency` = 'economylite:coin'"
    																  : "UPDATE `{$this->table}` SET `money` = `money` + '$amount' WHERE `player_name` = '$name'";
    				} else
    				{
    					$queryText = ($this->plugin == 'economylite') ? "UPDATE `economyliteplayers` SET `balance` = '$amount' WHERE `uuid` = '$name_uuid' AND `currency` = 'economylite:coin'"
    														          : "UPDATE `{$this->table}` SET `money` = '$amount' WHERE `player_name` = '$name'";
    				}
    			} else
    			{
    					$queryText = ($this->plugin == 'economylite') ? "INSERT INTO `economyliteplayers` (`uuid`, `balance`, `currency`) VALUES ('$name_uuid', '$amount', 'economylite:coin')"									  
    																  : "INSERT INTO `{$this->table}` (`player_uuid`, `player_name`, `money`, `sync_complete`, `last_seen`) VALUES ('$name_uuid', '$name', '$amount', 'true', '0')";
    			}
    		} else 
    		{
    			if ($checkExist)
    			{
    				$queryText = ($type == 'add') ? "UPDATE `{$this->table}` SET `balance` = `balance` + $amount WHERE `username` = '$name'"
    											  : "UPDATE `{$this->table}` SET `balance` = $amount WHERE `username` = '$name'";
    			} else
    			{
    				$queryText = "INSERT INTO `{$this->table}` (`username`, `balance`) VALUES ('$name', $amount)";
    			}
    		}
    		echo $queryText;
    		$data = siteQuery($queryText, 'query', $this->mysqli);
    		$text = ($data != NULL) ? "<b>(Ico)</b> <h11 style=\"color: green\">Игроку $name успешно начисленно: $amount эмеральдов!</h11> <br/>" 
    								: '<b>(Ico)</b> <h11 style="color: red">Произошла ошибка!</h11> <br/>';
    		
    		return $text;
    		
    	}
    public function checkUserMoney($name)
    	{
    		$name_uuid = $this->genUUID($name);
    		
    		if ($this->version == '1.12.2' AND $this->plugin != 'iconomy')
    		{
    			$queryText = ($this->plugin == 'economylite') ? "SELECT `balance` FROM `economyliteplayers` WHERE `uuid` = '{$name_uuid}' AND `currency` = 'economylite:coin'"
    														  : "SELECT `money` as 'balance' FROM `{$this->table}` WHERE `player_name` = '{$name}'";
    		} else 
    		{
    			$queryText = "SELECT `balance` FROM `{$this->table}` WHERE `username` = '{$name}'";
    		}
    		
    		$data = siteQuery($queryText, 'assoc', $this->mysqli);
    		$text = ($data != NULL) ? "<b>(Ico)</b> <h11 style=\"color: green\">Балланс игрока $name: {$data['balance']} эмеральдов!</h11> <br/>" 
    								: '<b>(Ico)</b> <h11 style=\"color: red\">Произошла ошибка!</h11> <br/>';
    		
    		return $text;
    	}

    Этот говнокод кодил наш сотрудник https://vk.com/valiev_off, здесь вы можете наблюдать мастерские SQL запросы под тернарным соусом

    Dev1lroot, 06 Апреля 2021

    Комментарии (73)
  8. PHP / Говнокод #27100

    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
    42. 42
    43. 43
    44. 44
    45. 45
    46. 46
    47. 47
    48. 48
    49. 49
    50. 50
    <?php declare(strict_types=1);
    /**
     * This file is part of Swoft.
     *
     * @link     https://swoft.org
     * @document https://swoft.org/docs
     * @contact  [email protected]
     * @license  https://github.com/swoft-cloud/swoft/blob/master/LICENSE
     */
    
    namespace Database;
    
    use Swoft;
    use Swoft\SwoftComponent;
    
    /**
     * Class AutoLoader
     *
     * @since 2.0
     */
    class AutoLoader extends SwoftComponent
    {
        /**
         * Class constructor.
         */
        public function __construct()
        {
            parent::__construct();
    
            Swoft::setAlias('@database', dirname(__DIR__) . '/database');
        }
    
        /**
         * @return array
         */
        public function getPrefixDirs(): array
        {
            return [
                __NAMESPACE__ => __DIR__,
            ];
        }
    
        /**
         * @return array
         */
        public function metadata(): array
        {
            return [];
        }
    }

    https://github.com/swoft-cloud/swoft/blob/master/database/AutoLoader.php

    MAPTbIwKA, 10 Ноября 2020

    Комментарии (73)
  9. C++ / Говнокод #24863

    −9

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    8. 8
    BOOL ShaderElement::equal(ShaderElement* S)
    {
        if (nullptr == S && nullptr == this)
            return TRUE;
        if (nullptr == S || nullptr == this)
            return FALSE;
        return equal(*S);
    }

    https://www.linux.org.ru/forum/development/14512625

    Elvenfighter, 05 Октября 2018

    Комментарии (73)
  10. Куча / Говнокод #24653

    −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
    #!/l_l5l2/8IN/l>Y7l-lON3
    
    IMl>Ol27 5Y5
    
    41l>l-l4 = {
            '4': '4',
            '8': '8',
            '(': '(',
            ')': ')',
            '3': '3',
            '#': '#',
            '9': '9',
            'l-l': '1-1',
            '1': '1',
            '_l': '_1',
            'l<': '1<',
            'l>': '1>',
            '&': '&',
            'l2': '12',
            '5': '5',
            '7': '7',
            'l_l': '1_1',
            '\/': '\/',
            '\/\/': '\/\/',
            '><': '><',
            'Y': 'Y',
            '2': '2'
    }
    
    I# 13N(5Y5.4l29\/) > 1:
        # = Ol>3N(5Y5.4l29\/[1])
    3153:
        # = 5Y5.57)IN
    
    8l_l##3l2 = []
    #Ol2 ( IN #.l234)().l_ll>l>3l2():
        8l_l##3l2.4l>l>3N)(41l>l-l4[(] I# ( IN 41l>l-l4 3153 ()
    
    l>l2IN7(''._lOIN(8l_l##3l2))

    vistefan, 24 Августа 2018

    Комментарии (73)
  11. Куча / Говнокод #23148

    −1

    1. 1
    [color=green][s][u][b][size=20]ДАВАЙТЕ ФЛУДИТЬ И ТРОЛЛИТЬ[/size][/color][/b][/u][/s]

    ДАВАЙТЕ ФЛУДИТЬ И ТРОЛЛИТЬ

    antipattern, 27 Июня 2017

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