1. C# / Говнокод #5124

    +113

    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
    let rnd = System.Random()
     
    // список из 10-ти случайных элементов
    let myList = [1..10] |> List.map (fun x -> rnd.Next(1, 100))
     
    // функция, исключающая элементы с нечётными номерами
    let removeEven lst = [
        let i = ref 0
        for n in lst do
            if (!i % 2 <> 0) then yield n
            i := !i + 1]
     
    // выводим список
    printfn "%A" myList
     
    // исключаем нечётные и выводим
    printfn "%A" (removeEven myList)

    qbasic, 01 Января 2011

    Комментарии (46)
  2. C# / Говнокод #5104

    +135

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    if (",0,1,2,5,6,9,10,11,14,17,18,".IndexOf("," + cc + ",") != -1)
    {
        gridwells[rid, cc].Editor = null;
        gridwells[rid, cc].View.BackColor = Mark_FormFunctions.DefColor;
    }
    else if (",3,4,7,8,15,12,13,".IndexOf("," + cc + ",") != -1)
    {
        gridwells[rid, cc].Editor = DoubleEditor;
        gridwells[rid, cc].View = Mark_FormFunctions.EditView;
    }

    Вот так можно обойтись без switch

    Buzurud, 29 Декабря 2010

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

    +122

    1. 1
    2. 2
    3. 3
    int valu=...;
    ...
    string vals=""+valu;

    Говногость, 28 Декабря 2010

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

    +124

    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
    /// <summary>
            /// Return "Yes" for true and "No" for false
            /// </summary>
            public static string GetYesNoString(this bool val) 
            {
                return val ? "Yes" : "No";
            }
    
            /// <summary>
            /// Return "N/A" if no value, "Yes" for true and "No" for false
            /// </summary>
            public static string GetYesNoString(this object val)
            {            
                if(val is bool)
                    return ((bool)val).GetYesNoString();
    
                return "N/A";
            }

    Extension of the object class :) Very stupid because it make sense only for bool type, but it can be selected for every type in intellisense :)

    bugotrep, 27 Декабря 2010

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

    +121

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    int finda(string[] strl, string a)
    {
    	int ii=0;
    	foreach(var i in strl)
    	{
    		if(a==i)
    			return ii;
    		ii++;//Тут нужно оптимизировать!!!
    	};
    }

    Говногость, 25 Декабря 2010

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

    +128

    1. 1
    if ((((((X >= -7) && (X<= -6) & (Y!=2)) || (X<= -2) && (X>= -6) && (Y<=0) && (Y>= -1) && (Y== 0.25*X + 0.5) || (X+ -2)*(X+ -2) + (Y+2)*(Y+2)==4) && (X >= -2) && (X<=0) && (Y>=0) && (Y<=2)|| (((X*X)+(Y*Y)==4)) && ((X>=0) && (X<=2) && (Y>=0) && (Y<=2))) || ((Y==0.5*X-1) && (X>=2) && (Y<=3) & (Y!=0)))) Console.WriteLine("Принадлежит");

    HIMen, 23 Декабря 2010

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

    +121

    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
    class RandomGeneratorFiveState : RandomGenerator {
        int zero, one, two, three, four, min, max;
        public RandomGeneratorFiveState(int min, int zero, int one, int two, int three, int four)
            : base() {
            max = min + (four != 0 ? 4 : three != 0 ? 3 : two != 0 ? 2 : one != 0 ? 1 : 0);
            this.min = min;
            this.zero = zero;
            this.one = this.zero + one;
            this.two = this.one + two;
            this.three = this.two + three;
            this.four = this.three + four;
        }
        public override int Next() {
            int n = Random.Next(four);
            if(n < zero) return min;
            if(n < one) return min + 1;
            if(n < two) return min + 2;
            if(n < three) return min + 3;
            return min + 4;
        }
        public override int GetMax() { return max; }
        public override int GetMin() { return min; }
    }

    amartynov, 23 Декабря 2010

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

    +110

    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
    protected void Page_Load(object sender, EventArgs e)
            {
                Common.CheckAuthorization(Response, Session);     
    
                string uniqueID = Request["__EVENTTARGET"];
                if (uniqueID != null)
                {
                    UpdatePanel.ContentTemplateContainer.Controls.Clear();
                    string controlPath;
                    Control control = GetViewControlOnEvent(uniqueID, out controlPath);
    
                    if (control != null)
                    {
                        UpdatePanel.ContentTemplateContainer.Controls.Add(control);
                        Helpers.SetKeyInSession(Common.CATALOG_KEYS.CONTROL_PATH, controlPath, Session);
                    }
                    else
                    {
                        UpdatePanel.ContentTemplateContainer.Controls.Add(
                            GetViewControlOnSession());
                    }
                }
                else
                {
                    if (ControlParam == null)
                        Helpers.SetKeyInSession(Common.CATALOG_KEYS.CONTROL_PATH, Common.PATHS.USER_CONTROLS.MAIN_CONTROL, Session);   
    
                    UpdatePanel.ContentTemplateContainer.Controls.Add(
                        GetViewControlOnSession());
                }
                TreeViewState.SaveTreeView(treeCatalogs, this.GetType().ToString());
    
                this.PreRender += OnPreRender;
            }

    Nigma143, 22 Декабря 2010

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

    +118

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    8. 8
    9. 9
    public void AllSolutionButtons(bool TrueOrFalse)
            {
                SetButtons("TopCorners", TrueOrFalse);
                SetButtons("TopWings", TrueOrFalse);
                SetButtons("BottomCorners", TrueOrFalse);
                SetButtons("BottomWings", TrueOrFalse);
                SetButtons("middleSlice", TrueOrFalse);
                SetButtons("Solve", TrueOrFalse);
            }

    У меня зла не хватает ...... как вообще так можно писать ... а главное как такое придумать можно %)

    Arbium, 22 Декабря 2010

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

    +109

    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
    private void btnSearch_Click(object sender, EventArgs e)
            {
                Thread thrd = new Thread(ShowProgress);
                if ((cbCategory.Text != "")
                    && (txtBoxCriteria.Text != ""))
                {
                    if (dgvFound.RowCount != 0)
                        dgvFound.Rows.Clear();// очистка результатов предыдущего поиска
                    thrd.Start(); // запуск прогресса в дополнительном потоке
                    frmSiteManager.tvDoc.BeginUpdate();
                    frmSiteManager.tvDoc.Nodes[cbCategory.SelectedIndex].Expand();
                    FindDocuments(frmSiteManager.tvDoc.Nodes[cbCategory.SelectedIndex].Nodes);
                    if (thrd.IsAlive)
                    {
                        Thread.Sleep(1000);
                        thrd.Abort();// завершить поток прогресса
                        thrd.Join();
                    }
                    fProgress.Close();
                    frmSiteManager.tvDoc.EndUpdate();
                    if (dgvFound.RowCount == 0)
                        MessageBox.Show("По Вашему запросу ничего не найдено.",
                                        "Результаты поиска",
                                        MessageBoxButtons.OK,
                                        MessageBoxIcon.Exclamation);
                }
                else
                    MessageBox.Show("Задайте пожалуйста критерии поиска.",
                                        "Поиск документа",
                                        MessageBoxButtons.OK,
                                        MessageBoxIcon.Error);
            }

    обработчик нажатия btnSearch_Click - находится в другой форме. в ДокСеарч )))
    А теперь объясните что здесь не правильно ?

    Maxim546, 21 Декабря 2010

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