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

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

    +135

    1. 1
    return ((((num & ~(0xFFFFFFFF << n)) >> (n - 0x1)) & 0x1) == 0x1) ? ((num & ~(0xFFFFFFFF << n)) ^ ~(0xFFFFFFFF << n)) + 0x1 : (num & ~(0xFFFFFFFF << n));

    EON8ight, 01 Сентября 2013

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

    +135

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    BoxOfIndex =[0,0,0,1,1,1,2,2,2,0,0,0,1,1,1,2,2,2,0,0,0,1,1,1,2,2,2,
                           3,3,3,4,4,4,5,5,5,3,3,3,4,4,4,5,5,5,3,3,3,4,4,4,5,5,5,
                           6,6,6,7,7,7,8,8,8,6,6,6,7,7,7,8,8,8,6,6,6,7,7,7,8,8,8]
    
    Box = BoxOfIndex[i*9 +j]

    Определение индекса малого квадрата в судоку

    Вместо
    Box = (i/3)*3 +j/3

    kegdan, 01 Сентября 2013

    Комментарии (21)
  4. C# / Говнокод #13451

    +124

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    8. 8
    9. 9
    class Comparer : IComparer<int>
    {
        Random random = new Random();
    
        public int Compare(int x, int y)
        {
            return 1 - random.Next() % 3;
        }
    }

    Ccik, 18 Июля 2013

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

    +79

    1. 1
    cout << "Hello world!";

    Паражают люди каторые думают што с++ язык праграмиравания Если нихватаит мазгов чтобы изучить html и css то лучшы не пазортися и ни учит всякие говно-языки типа с++ jawa pyton и т.д. Ищо называют сибя прагармистами неудачники

    PragramistOtBoga, 04 Июля 2013

    Комментарии (21)
  6. Куча / Говнокод #13283

    +132

    1. 001
    2. 002
    3. 003
    4. 004
    5. 005
    6. 006
    7. 007
    8. 008
    9. 009
    10. 010
    11. 011
    12. 012
    13. 013
    14. 014
    15. 015
    16. 016
    17. 017
    18. 018
    19. 019
    20. 020
    21. 021
    22. 022
    23. 023
    24. 024
    25. 025
    26. 026
    27. 027
    28. 028
    29. 029
    30. 030
    31. 031
    32. 032
    33. 033
    34. 034
    35. 035
    36. 036
    37. 037
    38. 038
    39. 039
    40. 040
    41. 041
    42. 042
    43. 043
    44. 044
    45. 045
    46. 046
    47. 047
    48. 048
    49. 049
    50. 050
    51. 051
    52. 052
    53. 053
    54. 054
    55. 055
    56. 056
    57. 057
    58. 058
    59. 059
    60. 060
    61. 061
    62. 062
    63. 063
    64. 064
    65. 065
    66. 066
    67. 067
    68. 068
    69. 069
    70. 070
    71. 071
    72. 072
    73. 073
    74. 074
    75. 075
    76. 076
    77. 077
    78. 078
    79. 079
    80. 080
    81. 081
    82. 082
    83. 083
    84. 084
    85. 085
    86. 086
    87. 087
    88. 088
    89. 089
    90. 090
    91. 091
    92. 092
    93. 093
    94. 094
    95. 095
    96. 096
    97. 097
    98. 098
    99. 099
    100. 100
    unit Unit1;
    
    interface
    
    uses
      Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
      Dialogs, StdCtrls;
    
      type
      tmythread=class(tthread)
      private
      filename:string;
      procedure execute;override;
      public
        constructor create(filename:string);
        destructor destroy;
      end;
    
    type
      TForm1 = class(TForm)
        Button2: TButton;
        Button3: TButton;
        procedure FormCreate(Sender: TObject);
        procedure Button2Click(Sender: TObject);
      private
        { Private declarations }
      public
        { Public declarations }
      end;
    
    var
      Form1: TForm1;
      tlst:tthreadlist;
    
    implementation
    
    {$R *.dfm}
    
    function getCount : integer;
    begin
        Result := tlst.LockList.Count;
        tlst.UnlockList;
    end;
    
    
    procedure TForm1.FormCreate(Sender: TObject);
    begin
    tlst:=tthreadlist.Create;
    end;
    
    { tmythread }
    
    constructor tmythread.create(filename: string);
    begin
      self.FreeOnTerminate:=true;
      self.filename:=filename;
      inherited create(true);
      self.Priority:=tphigher;
      self.Resume;
      tlst.LockList.Add(self);
      tlst.UnlockList;
    end;
    
    destructor tmythread.destroy;
    begin
    tlst.Remove(self);
    tlst.UnlockList;
    end;
    
    procedure tmythread.execute;
    begin
    while not terminated do
    sleep(100);    // в качестве примера, чем-то нагружаем цикл.
    end;
    
    procedure TForm1.Button2Click(Sender: TObject);
    var
      i:integer;
      n:string;
      temp:tmythread;
      s:string;
    begin
    try
      for i:=0 to getcount-1 do
      begin
        temp:=tlst.LockList.Items[i]; // вот это место. Как Вам кажется, это правильно, или не?
        if assigned(temp) then
        n:=temp.filename;
        if n='ololo' then   // это просто пример, не смеемся) АХАХАХАХ )
        begin
          showmessage('Сканирование этого файла уже выполняется') ;
          exit;
        end;
      end;
      tmythread.create('ololo');
      except
      end;
    end;
    
    end.

    Стоит задача сканировать файлы в разных потоках. Как Вам кажется, это адекватное решение?

    Код полностью.

    Stertor, 02 Июля 2013

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

    +133

    1. 1
    return Training.ContainsKey(typeof(unit)) ? true : false;

    А я ведь говорил ему не рефакторить на ночь глядя.

    RaZeR, 13 Июня 2013

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

    +155

    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
    if (!$left || !$right) return true;
            $sql = "DELETE FROM {$this->_tableName} WHERE `user_id`=$user_id";
            $this->_db->exec($sql);
    
            if (!$this->_isTriggers) {
                if (($right - $left) == 1) {
                    $sql = "UPDATE {$this->_tableName} SET `left`=IF(`left` >= $left,`left`-2,`left`),`right`=`right`-2 WHERE `right` >= $left";
                } else {
                    $sql = "UPDATE {$this->_tableName} SET 
                    `left`=IF(`left` BETWEEN $left AND $right,`left`-1,`left`),
                    `right`=IF(`right` BETWEEN $left AND $right,`right`-1,`right`),
                    `level`=IF(`left` BETWEEN $left AND $right,`level`-1,`level`),
                    `left`=IF(`left`>$right,`left`-2,`left`),
                    `right`=IF(`right`>$right,`right`-2,`right`)
    		WHERE `right` > $left
                    ";
                }
                $this->_db->exec($sql);

    Только ручной сбор запроса. Zend Db

    coderxlsn, 30 Мая 2013

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

    +136

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    8. 8
    9. 9
    public static bool isLaterThan()
    {
      string hd = DateTime.Now.ToString("tt", new CultureInfo("en-US")).ToLower();
    
      if (hd == "pm")
       return false;
    
       return DateTime.Now.Hour < 1;
    }

    уже есть час ночи?

    taburetka, 30 Мая 2013

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

    +138

    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
    // Преобразует BCD формат в число
    private static int BCDToInt(byte bIn)
    {
        return ((((bIn / 0x10) * 10) + bIn) - ((bIn / 0x10) * 0x10));
    }
    
    // Преобразует число в BCD формат
    private static byte IntToBCD(int value)
    {
        value -= (value / 100) * 100;
        byte bTH = (byte)(value / 10);
        byte bTL = (byte)(value - (bTH * 10));
        return (byte)(bTL + ((byte)(bTH << 4)));
    }

    навеяло сложными запутывающими большими и маленькими индейцами для элитных программистов

    референс-код от партнеров для конверсии binary-coded decimal вперёд и взад
    чтобы как бы верно срослось между ихним с# и нашим сраным с++

    defecate-plusplus, 29 Мая 2013

    Комментарии (21)
  11. ActionScript / Говнокод #12985

    −163

    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
    public function algorithmChanged(arg1:flash.events.Event):*
            {
                var loc1:*;
                loc1 = null;
                if (currentAlgorithm != null)
                    removeChild(currentAlgorithm);
                loc1 = arg1.target.selectedLabel;
                currentAlgorithm = null;
                animationManager.resetAll();
                if (loc1 != "Heap")
                    if (loc1 != "Comparison Sort")
                        if (loc1 != "Counting Sort")
                            if (loc1 != "Bucket Sort")
                                if (loc1 != "Radix Sort")
                                    if (loc1 != "Heap Sort")
                                        if (loc1 != "Binary Search Tree")
                                            if (loc1 != "AVL Tree")
                                                if (loc1 != "Open Hashing")
                                                    if (loc1 != "Closed Hashing")
                                                        if (loc1 != "Graph")
                                                            if (loc1 != "DFS")
                                                                if (loc1 != "BFS")
                                                                    if (loc1 != "Connected Components")
                                                                        if (loc1 != "Dijkstra")
                                                                            if (loc1 != "Prim")
                                                                                if (loc1 != "Kruskal")
                                                                                    if (loc1 != "Topological Sort")
                                                                                        if (loc1 != "Floyd-Warshall")
                                                                                            if (loc1 != "B Tree")
                                                                                                if (loc1 != "Binomial Queue")
                                                                                                    if (loc1 != "Disjoint Sets")
                                                                                                        if (loc1 != "Array Stack")
                                                                                                            if (loc1 != "Array Queue")
                                                                                                                if (loc1 != "Linked List Stack")
                                                                                                                    if (loc1 != "Linked List Queue")
                                                                                                                        if (loc1 != "Red Black Tree")
                                                                                                                            if (loc1 != "Closed Hashing (buckets)")
                                                                                                                                if (loc1 == "B+ Tree")
                                                                                                                                {
                                                                                                                                    currentAlgorithm = new BPlusTree(animationManager);
                                                                                                                                    addChildAt(currentAlgorithm, 0);
                                                                                                                                }
                                                                                                                            else 
                                                                                                                            {
                                                                                                                                currentAlgorithm = new ClosedHash2(animationManager);
                                                                                                                                addChildAt(currentAlgorithm, 0);
                                                                                                                            }
                                                                                                                        else 
                                                                                                                        {
                                                                                                                            currentAlgorithm = new RedBlackTree(animationManager);
                                                                                                                            addChildAt(currentAlgorithm, 0);
                                                                                                                        }
    и т.д. пока не закроются все if'ы

    Визуализатор сортировок университета Сан-Франциско

    alexprey, 12 Мая 2013

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