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

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

    +146

    1. 1
    2. 2
    3. 3
    4. 4
    void crash()
    {
        (( void(*)() )0)();
    }

    Good crash :D

    petersvp, 11 Сентября 2011

    Комментарии (43)
  3. Java / Говнокод #7711

    +76

    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
    public class Sorting {  
    
        private static void swapElements(int[] arr, int index1, int index2) {
            int temp = arr[index1];
            arr[index1] = arr[index2];
            arr[index2] = temp;
        }
    
        public static void mergeSort(int[] arr) {
            if (arr.length == 1) {
                return;
            }        
            final int temp = (arr.length % 2 == 0) ? arr.length / 2 : (arr.length + 1) / 2;
    
            int[] left = new int[temp];
            int[] right = new int[arr.length / 2];
            System.arraycopy(arr, 0, left, 0, temp);
            System.arraycopy(arr, temp, right, 0, arr.length / 2);
    
            Sorting.mergeSort(left);
            Sorting.mergeSort(right);
            Sorting.mergeSortHelper(arr, left, right);
        }
    
        private static void mergeSortHelper(int[] arr, int[] left, int[] right) {
            int L = 0, R = 0;
            boolean Ltop = false, Rtop = false;
    
            for (int i = 0; i < arr.length; i++) {
                if (L < left.length - 1 && R < right.length - 1) {
                    if (left[L] <= right[R]) {
                        arr[i] = left[L];
                        L++;
                    } else {
                        arr[i] = right[R];
                        R++;
                    }
                } else if ((L == left.length - 1) ^ (R == right.length - 1)) {
                    if (L == left.length - 1) {
                        if ((left[L] <= right[R]) && !Ltop) {
                            arr[i] = left[L];
                            Ltop = true;
                        } else {                        
                            arr[i] = right[R];
                            R++;
                        }
                    } else {
                        if ((right[R] <= left[L]) && !Rtop) {
                            arr[i] = right[R];
                            Rtop = true;
                        } else {                        
                            arr[i] = left[L];
                            L++;
                        }
                    }
                } else {
                    if (i < arr.length - 1) {
                        arr[i] = (left[L] < right[R]) ? left[L] : right[R];                    
                    } else {                    
                        arr[i] = (left[L] > right[R]) ? left[L] : right[R];
                    }
                }
            }        
        }

    Реализация сортировки слиянием на Java

    kaspvar, 31 Августа 2011

    Комментарии (43)
  4. Java / Говнокод #7547

    +76

    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
    class PseudoVamp {
    	public int num;
    	public boolean truevamp = false;
    	public int x;
    	public int y;
    	public int n1;
    	public int n2;
    	public int n3;
    	public int n4;
    
    	void breaknsort() {
    		n1 = num % 10;
    		n2 = num / 10 % 10;
    		n3 = num / 100 % 10;
    		n4 = num / 1000;
    		int tmp;
    		for (int i = 0; i < 4; i++) {
    			if (n1 > n2) {
    				tmp = n1;
    				n1 = n2;
    				n2 = tmp;
    			}
    
    			if (n2 > n3) {
    				tmp = n2;
    				n2 = n3;
    				n3 = tmp;
    			}
    
    			if (n3 > n4) {
    				tmp = n3;
    				n3 = n4;
    				n4 = tmp;
    			}
    		}
    	}
    
    	public PseudoVamp(int a, int b) {
    		x = a;
    		y = b;
    		num = x * y;
    		breaknsort();
    	}
    }
    
    public class Test {
    
    	static void checkvamp(PseudoVamp vamp) {
    		int x1 = vamp.x % 10;
    		int x2 = vamp.x / 10;
    
    		int y1 = vamp.y % 10;
    		int y2 = vamp.y / 10;
    
    		int tmp;
    		for (int i = 0; i < 4; i++) {
    			if (x1 > x2) {
    				tmp = x1;
    				x1 = x2;
    				x2 = tmp;
    			}
    
    			if (x2 > y1) {
    				tmp = x2;
    				x2 = y1;
    				y1 = tmp;
    			}
    
    			if (y1 > y2) {
    				tmp = y1;
    				y1 = y2;
    				y2 = tmp;
    			}
    		}
    		if (vamp.n1 == x1 && vamp.n2 == x2 && vamp.n3 == y1 && vamp.n4 == y2)
    			vamp.truevamp = true;
    	}
    
    	public static void main(String[] args) {
    		for (int i = 11; i < 100; i++) {
    			for (int j = 11; j < 100; j++) {
    				PseudoVamp v = new PseudoVamp(i, j);
    				if (v.num < 1000)
    					continue;
    				if (v.num > 9999)
    					return;
    				checkvamp(v);
    				if (v.truevamp)
    				System.out.println(v.x + " * " + v.y + " = " + v.num);
    			}
    		}
    	}
    }

    A vampire number has an even number of digits and is formed by multiplying a pair of numbers containing half the number of digits of the result. The digits are taken from the original number in any order. Pairs of trailing zeroes are not allowed. Examples include:
    1260 = 21 * 60
    1827 = 21 * 87
    2187 = 27 * 81
    Write a program that finds all the 4-digit vampire numbers.
    w/o using of arrays.

    ch0sen, 15 Августа 2011

    Комментарии (43)
  5. JavaScript / Говнокод #6672

    +160

    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
    if (__captcha.ammount > 0) {
        var captcha = new Array();
        
        for (var i in __captcha.queue) {
            captcha = __captcha.queue[i];
            delete __captcha.queue[i];
            break;
        }
        
        __captcha.ammount--;
        __update();
        
        return captcha;
    }

    w100, 14 Мая 2011

    Комментарии (43)
  6. Pascal / Говнокод #6617

    +103

    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
    function TForm1.getyoutube(ss: string): string;
    var
    //Вылавливаем ссылку
    i:integer;
    pos:integer;
    length1:integer;
    ssylka:string;
    pos_str:string;
    //Удаляем ненужные символы
    pos_str2:string;
    pos2,pos23:integer;
    ssc:char;
    begin
    //Вылавливаем ссылку если это ютубовская ссылка
    if isitok('youtube.com',ss)=true then
    begin
      protect;
      memo1.lines.Text:=idhttp1.Get(ss);
      for i:=0 to memo1.Lines.Count do
      begin
      pos_str:='				img.src = '+#39;
      pos:=AnsiPos(pos_str,memo1.Lines.Strings[i]);
      if pos=1 then
      begin
      length1:=length(memo1.Lines.Strings[i])-length(pos_str)-2;
       ssylka:=copy(memo1.Lines.Strings[i],pos+length(pos_str),length1);
        end;
        end;
        ssc:=#160;
         pos_str:='youtube.com';
        pos:=AnsiPos(pos_str,ssylka);
        delete(ssylka,pos+length(pos_str),1);
        delete(ssylka,6,1);
        delete(ssylka,7,1);
          pos_str2:='youtube.com/';
        pos2:=AnsiPos(pos_str,ssylka);
        pos2:=pos2+length(pos_str2);
           pos_str2:='?ip';
        pos23:=AnsiPos(pos_str,ssylka);
        delete(ssylka,pos2,pos2-pos23);
        insert('videoplayback',ssylka,pos2);
        result:=ssylka;
        end
        else
        begin
          protectoff;
        form2.show;
          form1.enabled:=false;
        end;
          protectoff;
    end;

    Очень старый способ скачать видео с YouTube

    KapoeD, 10 Мая 2011

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

    +160

    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
    #include <stdio.h>
    #include <boost/typeof/typeof.hpp>
    
    template<class T>
    struct __macro
    {
    	__declspec(thread) static T _;
    };
    
    template<class T>
    T __macro<T>::_;
    
    #define def(c) (__macro<typeof(c)>::_ = c)
    #define acc(c) (__macro<typeof(c)>::_)
    
    #define is_digit(x) (def(x),(acc(x) >= '0' && acc(x) <= '9') ? true : false)
    #define is_bugit(x) ((x >= '0' && x <= '9') ? true : false)
    
    int main()
    {
    	char hj;
    	
    	hj = '9';
    	printf("test->") && is_bugit(hj++) && printf("ok\n") || puts("no");
    
    	hj = '9';
    	printf("test->") && is_digit(hj++) && printf("ok\n") || puts("no");
    }

    e113c08d6cf14afb, 07 Мая 2011

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

    +158

    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
    /*
    -----------------------------------------------------------------
    Формируем Карту Сайта и записываем в Кэш
    -----------------------------------------------------------------
    */
    function sitemap() {
        global $rootpath, $realtime, $set;
        $links_count = 140;
        $file = $rootpath . 'files/cache/sitemap.dat';
        if (file_exists($file) && filemtime($file) > ($realtime - 604800)) {
            // Считываем ссылки из Кэша
            return file_get_contents($file);
        } else {
            $out = '';
            // Карта Форума
            $req = mysql_query("SELECT * FROM `forum` WHERE `type` = 'r'");
            if (mysql_num_rows($req)) {
                $out .= '<b>Forum Map</b>' . "\r\n";
                while ($res = mysql_fetch_assoc($req)) {
                    $count = mysql_result(mysql_query("SELECT COUNT(*) FROM `forum` WHERE `refid` = '" . $res['id'] . "' AND `type` = 't' AND `close` != '1'"), 0);
                    if ($count) {
                        $text = html_entity_decode($res['text']);
                        $text = mb_substr($text, 0, 30);
                        // Подсчитываем число блоков ссылок
                        $pages = ceil($count / $links_count);
                        if($pages > 1){
                            for($i = 0; $i < $pages; $i++){
                                $out .= '<br /><a href="' . $set['homeurl'] . '/sitemap/forum.php?id=' . $res['id'] . '&amp;p=' . $i . '">' . functions::checkout($text) . ' (part ' . ($i + 1) . ')</a>' . "\r\n";
                            }
                        } else {
                            $out .= '<br /><a href="' . $set['homeurl'] . '/sitemap/forum.php?id=' . $res['id'] . '">' . functions::checkout($text) . '</a>' . "\r\n";
                        }
                    }
                }
            }
            // Карта Библиотеки
            $req = mysql_query("SELECT * FROM `lib` WHERE `type` = 'cat' AND `ip` = '0'");
            if (mysql_num_rows($req)) {
                $out .= '<br /><br /><b>Library Map</b>' . "\r\n";
                while ($res = mysql_fetch_assoc($req)) {
                    $text = html_entity_decode($res['text']);
                    $text = mb_substr($text, 0, 30);
                    $out .= '<br /><a href="../library/index.php?id=' . $res['id'] . '">' . functions::checkout($text) . '</a>' . "\r\n";
                }
            }
            if (!empty($out)) {
                // записываем Кэш ссылок
                if (!file_put_contents($file, $out)) {
                    return 'Cache file write error!';
                }
                return $out;
            } else {
                return false;
            }
        }
    }
    
    /*
    -----------------------------------------------------------------
    Показываем карту сайта
    -----------------------------------------------------------------
    */
    if (!defined('_IN_JOHNCMS')) {
        define('_IN_JOHNCMS', 1);
        require('../incfiles/core.php');
        require('../incfiles/head.php');
        echo '<div class="menu">' . sitemap() . '</div>';
        require('../incfiles/end.php');
    } else {
            echo '<div class="menu"><div class="sitemap">' . sitemap() . '</div></div>';
    }

    JohnCMS 4, sitemap/index.php
    Этот движок, кстати, почти самый распространнённый в wap

    NadiaVita, 28 Декабря 2010

    Комментарии (43)
  9. Си / Говнокод #4560

    +146

    1. 1
    2. 2
    3. 3
    4. 4
    logit("e", "%s No Menu! Wait 5 minutes and try again.\n", whoami);
    for(j=0;j<60;j++) {
        sleep_ew( 5000 );       /* wait around */
    }

    sgram из earthworm

    ftptrash, 08 Ноября 2010

    Комментарии (43)
  10. PHP / Говнокод #3398

    +162

    1. 1
    2. 2
    3. 3
    4. 4
    $res = $db->loadResult();
    if($res); else return false;
    if($res!=$user->id) return false;
    return true;

    vsu, 04 Июня 2010

    Комментарии (43)
  11. Java / Говнокод #3340

    +144

    1. 1
    2. 2
    3. 3
    void method() {
        if(true) return;
    }

    только что встретилось, всем коллективом ржали

    немного классики, что бы не забывали.
    однозначно поле для действий, но все равно забавно

    Lure Of Chaos, 28 Мая 2010

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