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

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

    +119

    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
    public static Bitmap DrawBarsChart(ChartType t, Size s)
        {
          double[] values = DataValues;
          string[] names = DataNames;
          Bitmap bmp = new Bitmap(s.Width, s.Height);
          if (t != ChartType.bars || names.Length != values.Length || names.Length < 2)
            return bmp;
          else
          {
            Graphics g = Graphics.FromImage(bmp as Image);
            g.Clear(Color.White);
            g.DrawLines(new Pen(Brushes.Black), new Point[] { new Point(20, 20), new Point(20, s.Height - 20), new Point(s.Width - 200, s.Height - 20) });
            int Columnwidth = (s.Width - 240) / values.Length;
            if (Columnwidth > 150) Columnwidth = 150;
            double maxvalue = values.Max();
            int counter = 1;
            int rangefirst;
            int rangesecond;
     
            while (true)
            {
              if (maxvalue / Math.Pow(10, counter) < 10)
              {
                rangefirst = (int)Math.Floor(maxvalue / Math.Pow(10, counter));
                rangesecond = (int)(maxvalue - rangefirst * Math.Pow(10, counter));
                break;
              }
              else
              {
                counter++;
              }
            }
            int rangepix = (s.Height - 60) / (rangefirst + 1);
            for (int i = 0; i < rangefirst + 1; i++)
            {
              g.DrawString((i * Math.Pow(10, counter)).ToString(), new Font(FontFamily.GenericSansSerif, 10, FontStyle.Regular),
                Brushes.Black, new PointF(0, s.Height - 30 - rangepix * i));
              g.DrawLine(new Pen(Brushes.Black), new Point(17, s.Height - 20 - rangepix * i), new Point(20, s.Height - 20 - rangepix * i));
            }
            Colors colors = new Colors(); //класс-контейнер цветов (99 штук)
            int startcolor = new Random(DateTime.Now.Millisecond).Next(99);
            int j = startcolor;
            int startx = 21;
            int ColumnNumber = 1;
            foreach (var value in values)
            {
              int curfirstrange = (int)Math.Floor(value / Math.Pow(10, counter));
              int cursecondrange = (int)(value - curfirstrange * Math.Pow(10, counter));
              int rangesmallpix = (int)(cursecondrange * rangepix / Math.Pow(10, counter));
              g.FillRectangle(new SolidBrush(colors.GetNextColor(j)), startx,
                s.Height - 20 - curfirstrange * rangepix - rangesmallpix, Columnwidth, curfirstrange * rangepix + rangesmallpix);
              g.DrawString(value.ToString(), new Font(FontFamily.GenericSerif, 10, FontStyle.Regular), new SolidBrush(Color.Black), new PointF(startx + Columnwidth / 2 - 10,
                s.Height - 20 - curfirstrange * rangepix - rangesmallpix - 20));
              g.DrawString(ColumnNumber.ToString(), new Font(FontFamily.GenericSerif, 10, FontStyle.Regular), new SolidBrush(Color.Black), new PointF(startx + Columnwidth / 2 - 10,
                s.Height - 10));
              ColumnNumber++;
              j++; if (j > 99) j = 0;
              startx += Columnwidth;
            }
            j = startcolor;
            int TopMargin = 20;
            foreach (string str in names)
            {
              string tmp = str;
              if (str.Length > 15)
                tmp = str.Substring(0, 15);
              g.FillRectangle(new SolidBrush(colors.GetNextColor(j)), s.Width - 200, TopMargin, 10, 10); //pucyeM LIBeTHbIe kBagpaTuku
              g.DrawString(tmp, new Font(FontFamily.GenericSerif, 12, FontStyle.Italic), Brushes.Black, new PointF(s.Width - 180, TopMargin - 6)); //pucyeM Hagnucu
              TopMargin += 20;
              j++; if (j > 99) j = 0;
            }
            return bmp;
          }
        }

    qbasic, 06 Мая 2011

    Комментарии (17)
  3. C# / Говнокод #6458

    +119

    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
    private void Form1_Paint(object sender, PaintEventArgs e)
            {
                Graphics p=e.Graphics;
                p.DrawRectangle(Pens.Black, 100, 100, 120, 120);
                p.DrawLine(Pens.Black, 100, 100, 150, 80);
                p.DrawLine(Pens.Black, 220, 100, 270, 80);
                p.DrawLine(Pens.Black, 270, 80, 150, 80);
                p.DrawLine(Pens.Black, 220, 220, 270, 190);
                p.DrawLine(Pens.Black, 270, 190, 270, 80);
                p.DrawLine(Pens.Black, 140, 100, 140, 220);//Вертикальные линнии
                p.FillRectangle(Brushes.Beige, 101, 101, 39, 39);
                p.FillRectangle(Brushes.Brown, 101, 141, 39, 39);
                p.FillRectangle(Brushes.DarkBlue, 101, 181, 39, 39);
                p.FillRectangle(Brushes.ForestGreen, 141, 101, 39, 39);
                p.FillRectangle(Brushes.LightGreen, 181, 101, 39, 39);
                p.FillRectangle(Brushes.MediumTurquoise, 141, 141, 39, 39);
                p.FillRectangle(Brushes.OrangeRed, 181, 181, 39, 39);
                p.FillRectangle(Brushes.Orchid, 141, 181, 39, 39);
                p.FillRectangle(Brushes.Plum, 181, 141, 39, 39);
                p.DrawLine(Pens.Black, 180, 100, 180, 220);//Вертикальные  линнии
                p.DrawLine(Pens.Black, 100, 140, 220, 140);// Горихонтальные линнии
                p.DrawLine(Pens.Black, 100, 180, 220, 180);// Горихонтальные линнии
                p.DrawLine(Pens.Black, 140, 100, 190, 80);
                p.DrawLine(Pens.Black, 180, 100, 230, 80);
                p.DrawLine(Pens.Black, 220, 140, 270, 115);
                p.DrawLine(Pens.Black, 220, 180, 270, 155);
                p.DrawLine(Pens.Black, 121, 92, 239, 92);
                p.DrawLine(Pens.Black, 137, 86, 253, 86);
                p.DrawLine(Pens.Black, 239, 92, 239, 209);
                p.DrawLine(Pens.Black, 253, 86, 253, 200);
            }

    Рисуем одну грань кубика Рубика.

    http://www.cyberforum.ru/csharp-beginners/thread281606.html

    psina-from-ua, 23 Апреля 2011

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

    +119

    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
    RegistryKey readKey = Registry.CurrentUser.OpenSubKey("SOFTWARE\\Webzen\\Mu\\Config\\");
            Microsoft.Win32.RegistryKey regKey = Microsoft.Win32.Registry.CurrentUser;
            RegistryKey saveKey = Registry.CurrentUser.CreateSubKey("SOFTWARE\\Webzen\\Mu\\Config\\");
    
            private void b_exit_Click(object sender, EventArgs e)
            {
                if (checkBox1.Checked == true)
                    saveKey.SetValue("WindowMode", (int)0x00000001, Microsoft.Win32.RegistryValueKind.DWord);
                else
                    saveKey.SetValue("WindowMode", (int)0x00000000, Microsoft.Win32.RegistryValueKind.DWord);
                if (checkBox2.Checked == true)
                    saveKey.SetValue("MusicOnOff", (int)0x00000001, Microsoft.Win32.RegistryValueKind.DWord);
                else
                    saveKey.SetValue("MusicOnOff", (int)0x00000000, Microsoft.Win32.RegistryValueKind.DWord);
                if (checkBox3.Checked == true)
                    saveKey.SetValue("SoundOnOff", (int)0x00000001, Microsoft.Win32.RegistryValueKind.DWord);
                else
                    saveKey.SetValue("SoundOnOff", (int)0x00000000, Microsoft.Win32.RegistryValueKind.DWord);
                if (comboBox1.SelectedItem == "800x600")
                    saveKey.SetValue("Resolution", (int)0x00000001, Microsoft.Win32.RegistryValueKind.DWord);
                else if (comboBox1.SelectedItem == "1024x768")
                    saveKey.SetValue("Resolution", (int)0x00000002, Microsoft.Win32.RegistryValueKind.DWord);
                else if (comboBox1.SelectedItem == "1280x1024")
                    saveKey.SetValue("Resolution", (int)0x00000003, Microsoft.Win32.RegistryValueKind.DWord);
                saveKey.Close();
                this.Close();
            }
    
            private void Options_Load(object sender, EventArgs e)
            {
                XmlDocument cfg = new XmlDocument();
                cfg.Load("cfg.xml");
                String lang = cfg.GetElementsByTagName("language")[0].InnerText;
                if (lang == "en")
                {
                    checkBox1.Text = "In window";
                    checkBox3.Text = "Music";
                    checkBox2.Text = "Sounds";
                    label1.Text = "Resolution game";
                    b_exit.Text = "Save";
                    b_cancel.Text = "Cancel";
                }
                int loadString = (int)readKey.GetValue("WindowMode");
                if (loadString == 1)
                    checkBox1.Checked = true;
                int loadString2 = (int)readKey.GetValue("MusicOnOff");
                if (loadString2 == 1)
                    checkBox2.Checked = true;
                int loadString3 = (int)readKey.GetValue("SoundOnOff");
                if (loadString3 == 1)
                    checkBox3.Checked = true;
                if (readKey.GetValue("Resolution") == null)
                {
                    regKey.CreateSubKey("SOFTWARE\\Webzen\\Mu\\Config");
                    regKey.SetValue("Resolution", (int)0x00000001, Microsoft.Win32.RegistryValueKind.DWord);
                }
                else
                {
                    int loadString4 = (int)readKey.GetValue("Resolution");
                    if (loadString4 == (int)0x00000001)
                        comboBox1.Text = "800x600";
                    else if (loadString4 == (int)0x00000002)
                        comboBox1.Text = "1024x768";
                    else if (loadString4 == (int)0x00000003)
                        comboBox1.Text = "1280x1024";
                    else
                        comboBox1.Text = "Выберите разрешение";
                }
                readKey.Close();
            }

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

    daffsik, 06 Апреля 2011

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

    +119

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    8. 8
    9. 9
    try
    {
         selectedDate = Calendar1.SelectedDate.AddMilliseconds(-1);
         selectedDate = Calendar1.SelectedDate;
    }
    catch (Exception)
    {
          selectedDate = DateTime.Now.Date;
    }

    Ну вот как-то так пытался отловить дефолтовое значение календаря.

    partizan, 06 Апреля 2011

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

    +119

    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
    string[] otgruzka = new string[11] { "Отгрузка компонент 1 Вес 5дк-500", "Отгрузка компонент 2 Вес 5дк-500", "Отгрузка компонент 3 Вес 5дк-500", "Отгрузка компонент 4 Вес 5дк-500", "Отгрузка компонент 5 Вес 5дк-500", "Отгрузка компонент 6 Вес 5дк-500", "Отгрузка компонент 1 Вес 5дк-200", "Отгрузка компонент 2 Вес 5дк-200", "Отгрузка компонент 3 Вес 5дк-200", "Отгрузка компонент 4 Вес 5дк-200", "Отгрузка компонент 5 Вес 5дк-200", };
                        string[] silos = new string[11] { "Силос 1", "Силос 5", "Силос 6", "Силос 7", "Силос 8", "Силос 31-H", "Силос 9", "Силос 11", "Силос 2", "Силос 3", "Силос 4" };
                                           
                        for (int i = 0; i < dataGridView1.RowCount; i++)
                        {
                            if (Convert.ToString(dataGridView1.Rows[i].Cells[5].Value) == "Силос 1")
                                dataGridView1.Rows[i].Cells[3].Value = modbus_master.GetValue(otgruzka[0]);
                            if (Convert.ToString(dataGridView1.Rows[i].Cells[5].Value) == "Силос 5")
                                dataGridView1.Rows[i].Cells[3].Value = modbus_master.GetValue(otgruzka[1]);
                            if (Convert.ToString(dataGridView1.Rows[i].Cells[5].Value) == "Силос 6")
                                dataGridView1.Rows[i].Cells[3].Value = modbus_master.GetValue(otgruzka[2]);
                            if (Convert.ToString(dataGridView1.Rows[i].Cells[5].Value) == "Силос 7")
                                dataGridView1.Rows[i].Cells[3].Value = modbus_master.GetValue(otgruzka[3]);
                            if (Convert.ToString(dataGridView1.Rows[i].Cells[5].Value) == "Силос 8")
                                dataGridView1.Rows[i].Cells[3].Value = modbus_master.GetValue(otgruzka[4]);
                            if (Convert.ToString(dataGridView1.Rows[i].Cells[5].Value) == "Силос 31-H")
                                dataGridView1.Rows[i].Cells[3].Value = modbus_master.GetValue(otgruzka[5]);
                            if (Convert.ToString(dataGridView1.Rows[i].Cells[5].Value) == "Силос 9")
                                dataGridView1.Rows[i].Cells[3].Value = modbus_master.GetValue(otgruzka[6]);
                            if (Convert.ToString(dataGridView1.Rows[i].Cells[5].Value) == "Силос 11")
                                dataGridView1.Rows[i].Cells[3].Value = modbus_master.GetValue(otgruzka[7]);
                            if (Convert.ToString(dataGridView1.Rows[i].Cells[5].Value) == "Силос 2")
                                dataGridView1.Rows[i].Cells[3].Value = modbus_master.GetValue(otgruzka[8]);
                            if (Convert.ToString(dataGridView1.Rows[i].Cells[5].Value) == "Силос 3")
                                dataGridView1.Rows[i].Cells[3].Value = modbus_master.GetValue(otgruzka[9]);
                            if (Convert.ToString(dataGridView1.Rows[i].Cells[5].Value) == "Силос 4")
                                dataGridView1.Rows[i].Cells[3].Value = modbus_master.GetValue(otgruzka[10]);
                        }                    
                        textBox12.Text = Convert.ToString(modbus_master.GetValue("Текущий отвес 5дк-200") + 1);
    
                        if (modbus_master.GetValue("Текущий отвес 5дк-200") > WorkWithArchive.currentOtves200)
                        {
                            WorkWithArchive.WriteArchiveOtves200(modbus_master.GetValue("Текущий отвес 5дк-200"));
                            WorkWithArchive.currentOtves200 = modbus_master.GetValue("Текущий отвес 5дк-200");
                            WorkWithArchive.WriteArchiveKomponent200(dataGridView1);
                            WorkWithArchive.ot200 = true;
                        }

    Программа управления на производстве, взаимодействует с контроллером, получает кучу данных и такую же кучу отправляет.

    fxlancer, 05 Апреля 2011

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

    +119

    1. 1
    http://rabota.1777.ru/one_rezume.php?job_rezume_id=33838&job_cat_id2=1&doljnost2=&pol2=&vozrast_ot2=21&vozrast_do2=21&obrazovanie2=&opit2=&plata2=&pajina=&new=&doljnost3=

    Супер человек, всего 21 год, умеет все и деньги ему не нужны.

    Vasiliy, 18 Марта 2011

    Комментарии (0)
  8. Pascal / Говнокод #5992

    +119

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    Function F1(z: Byte): Real;  {Функция возведения (-1) в степень "к"}
    
      Begin
    
        If z=1
    
          Then F1:=-1
    
          Else F1:=F1(z-1)*-1;
    
      End;

    Нашел в лабораторной по вычмату 2-х годичной давности)

    1_and_0, 15 Марта 2011

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

    +119

    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
    Microsoft.Win32.RegistryKey Fregistry =
                    Microsoft.Win32.Registry.LocalMachine.OpenSubKey("SOFTWARE")
                    .OpenSubKey("Microsoft").OpenSubKey("Windows").OpenSubKey("CurrentVersion")
                    .OpenSubKey("Installer").OpenSubKey("UserData")
                    .OpenSubKey("S-1-5-18").OpenSubKey("Products");
                string []Names = Fregistry.GetSubKeyNames() ;
                string uninstall = "";
                string ApplicationName = "Adobe Reader 7.0.8";
                for (int i = 0; i < Names.Length; i++)
                {
                    Microsoft.Win32.RegistryKey FTemp = Fregistry.OpenSubKey(Names[i]).OpenSubKey("InstallProperties");
                    if (FTemp.GetValue("DisplayName").ToString() == ApplicationName)
                    {
                        object obj = FTemp.GetValue("UninstallString");
                        if (obj == null)
                            uninstall = "";
                        else
                            uninstall = obj.ToString();
                        i = Names.Length; 
                    }
                }
     
                System.Console.WriteLine(uninstall);
                System.Diagnostics.Process FProcess = new System.Diagnostics.Process();
                string temp = "/x{" + uninstall.Split("/".ToCharArray())[1].Split("I{".ToCharArray())[2];
                FProcess.StartInfo.FileName = uninstall.Split("/".ToCharArray())[0];
                FProcess.StartInfo.Arguments = temp;
                FProcess.StartInfo.UseShellExecute = false;
                FProcess.Start();
                System.Console.Read();

    qbasic, 03 Марта 2011

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

    +119

    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
    int buf;
                    for (int j = 1; j < srows.Length; j++)
                        for (int i = 0; i < srows.Length - j; i++)
                        {
                            if (vrows[i] > vrows[i + 1])
                            {
                                buf = vrows[i];
                                vrows[i] = vrows[i + 1];
                                vrows[i + 1] = buf;
    
                                buf = srows[i];
                                srows[i] = srows[i + 1];
                                srows[i + 1] = buf;
                            }
                        }

    В коде формы. (c) EGAR

    jonie, 28 Февраля 2011

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

    +119

    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
    public enum PageType
    {
        Default,
        Billing,
        UserCabinet
    }
    
    public PageType GetPageType(int code)
    {
         if(code == 1){return PageType.Default;}
         if(code == 2){return PageType.Billing;}
         if(code == 3){return PageType.UserCabinet;}
         return PageType.Default;
    }
    
    private int PageType
    {
        get
        {
                int page;
                Int32.TryParse(Request["page"], out page);
                return page;
        }
    }

    Думаю что объяснять тут ничего не нужно...

    Arnezami, 13 Января 2011

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