1. C++ / Говнокод #7336

    +177

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    int arr[100][100];
    
    for (int i = 0; i < 100; i++) {
       for (int j = 0; j < 100; j++) {
           if (i == j) arr[i][j] = 0;
       }
    }

    Когда-то работал в универе и увидел у одной девочки в лабораторном отчете.
    Код обнуляет диагональ массива, если кто сразу не понял)

    sotlef, 25 Июля 2011

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

    +164

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    if(isset( $out[1][2]) &amp;&amp;  trim($out[1][2]) !='') $arr['ns'].=', '. $out[1][2];
    if(isset( $out[1][3]) &amp;&amp;  trim($out[1][3]) !='') $arr['ns'].=', '. $out[1][3];
    if(isset( $out[1][4]) &amp;&amp;  trim($out[1][4]) !='') $arr['ns'].=', '. $out[1][4];
    if(isset( $out[1][5]) &amp;&amp;  trim($out[1][5]) !='') $arr['ns'].=', '. $out[1][5];
    if(isset( $out[1][6]) &amp;&amp;  trim($out[1][6]) !='') $arr['ns'].=', '. $out[1][6];
    if(isset( $out[1][7]) &amp;&amp;  trim($out[1][7]) !='') $arr['ns'].=', '. $out[1][7];

    Нашел на фри-ланс.ру

    Jesus, 25 Июля 2011

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

    −132

    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
    Запрос = Новый Запрос;
       Запрос.УстановитьПараметр("ин_Кодификатор",Кодификатор);
       Запрос.Текст =  "ВЫБРАТЬ
       | СтатьиДвиженияДенежныхСредств.Ссылка
       |ИЗ
       | Справочник.СтатьиДвиженияДенежныхСредств КАК СтатьиДвиженияДенежныхСредств
       |ГДЕ
       | СтатьиДвиженияДенежныхСредств.ин_Кодификатор = &ин_Кодификатор
       |";
       
       Выборка = Запрос.Выполнить().Выбрать();
       Если Выборка.Следующий() Тогда   
        Если  Выборка.Ссылка.Наименование <> Наименование Тогда
         СтатьяДДСОбъект = Выборка.Ссылка.ПолучитьОбъект();      
         СтатьяДДСОбъект.Наименование = Наименование;
         СтатьяДДСОбъект.Записать(); 
        КонецЕсли;
        Если  Выборка.Ссылка.ин_Кодификатор <> Кодификатор Тогда
         СтатьяДДСОбъект = Выборка.Ссылка.ПолучитьОбъект();         
         СтатьяДДСОбъект.ин_Кодификатор = Кодификатор;
         СтатьяДДСОбъект.Записать(); 
        КонецЕсли;

    Отбор в запросе ин_Кодификатор = &ин_Кодификатор.
    Потом идет проверка Выборка.Ссылка.ин_Кодификатор <> Кодификатор

    s-in-m, 25 Июля 2011

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

    +146

    1. 1
    http://dl.dropbox.com/u/24195734/gets/govnoget7333.png

    Гет, нах

    KirAmp, 25 Июля 2011

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

    +146

    1. 1
    Я заебался жать на рефреш весь долбанный день со всех устройств, чтобы запостить гет

    KirAmp, 25 Июля 2011

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

    +147

    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 class Matrix {
    
        private float matrix[][];
        private int dim;
    
        public Matrix(int dim) {
            this.dim = dim;
            this.matrix = new float[dim][dim];
        }
    
        public void productOfTwo(Matrix src, Matrix dest) {
            if (src.dim == this.dim) {
                dest.dim = this.dim;
    
                Matrix[] temp = new Matrix[this.dim];
                for (int i = 0; i < this.dim; i++) {
                    temp[i] = new Matrix(this.dim);
                }
    
                for (int i = 0; i < this.dim; i++) {
                    for (int j = 0; j < this.dim; j++) {
                        for (int k = 0; k < this.dim; k++) {
                            temp[k].matrix[i][j] = this.matrix[i][k] * src.matrix[k][j];
                        }
                    }
                }
              
                for (int i = 0; i < this.dim; i++) {
                    dest.sum(temp[i]);
                }
            } else {
                System.out.println("  An error occured: Dimensions of matrices do not match");
            }
        }
    
        public float findDet() {
            if (this.dim == 1) {
                return this.matrix[0][0];
            } else if (this.dim == 2) {
                return this.matrix[0][0] * this.matrix[1][1] - this.matrix[0][1] * this.matrix[1][0];
            } else {
                float result = 0;
                Matrix minor = new Matrix(this.dim - 1);
                for (int i = 0; i < this.dim; i++) {
                    for (int j = 1; j < this.dim; j++) {
                        System.arraycopy(this.matrix[j], 0, minor.matrix[j - 1], 0, i);
                        System.arraycopy(this.matrix[j], i + 1, minor.matrix[j - 1], i, this.dim - (i + 1));
                    }
                    result += Math.pow(-1, i) * this.matrix[0][i] * minor.findDet();
                }
                return result;
            }
        }

    Всем доброго времени суток! Прошу к Вашему вниманию алгоритм нахождения произведения двух матриц(умножаем слева направо) и нахождения детерминанта разложением по столбцу(рекурсия). Прошу оценить, по всей строгости.
    Заранее спасибо!

    kaspvar, 24 Июля 2011

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

    +958

    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
    namespace sortFiles
    {
        public partial class Form1 : Form
        {
            private void listBox1_DragDrop(object sender, DragEventArgs e)
            {
                this.listBox1.Items.AddRange((string[])e.Data.GetData(DataFormats.FileDrop, false));
            }
    
            private void listBox1_DragEnter(object sender, DragEventArgs e)
            {
                e.Effect = (e.Data.GetDataPresent(DataFormats.FileDrop) ? DragDropEffects.Copy : DragDropEffects.None);
            }
    
            private void listBox1_MouseDown(object sender, MouseEventArgs e)
            {
                var files = new List<OrderByMyCamera>();
                foreach (string i in listBox1.Items)
                    files.Add(new OrderByMyCamera(i));
                if(files.Count==0)
                    return;
                files.Sort();
                var filesArray = files.Select(item=>item.ToString()).ToArray();
                DoDragDrop(new DataObject(DataFormats.FileDrop, filesArray), DragDropEffects.Copy);
            }
        }
    
        internal class OrderByMyCamera : IComparable<OrderByMyCamera>
        {
            private readonly string _filePath;
            private readonly int _fileNumber;
    
            public OrderByMyCamera(string filePath)
            {
                _filePath = filePath;
                var fileName = Path.GetFileNameWithoutExtension(filePath);
                if(fileName.Count()!=6)
                    throw new Exception("Имя файла должно быть 6+4 символов вида MOVXXX.mpg. Возможно вы попытались вставить не те файлы в программу");
                if (!filePath.Trim().ToLower().EndsWith(".mpg"))
                    throw new Exception("Файлы должны заканчиваться на расширение .mpg. Сконвертируете файлы в mpeg, прежде чем вставите их в программу");
                int fileNumber = int.Parse(fileName.Substring(3), NumberStyles.HexNumber);
                _fileNumber = fileNumber;
            }
    
           public override string ToString()
            {
                return _filePath;
            }
    
            public int CompareTo(OrderByMyCamera other)
            {
                if (_fileNumber == other._fileNumber)
                    return 0;
                return (_fileNumber > other._fileNumber ? 1 : -1);
            }
        }
    }

    Говногость, 24 Июля 2011

    Комментарии (19)
  8. JavaScript / Говнокод #7329

    +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
    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
    jQuery.each(elems, function(i, elem) {
                    if (typeof elem === "number") {
                        elem += "";
                    }
                    if (!elem) {
                        return;
                    }
                    if (typeof elem === "string" && !rhtml.test(elem)) {
                        elem = context.createTextNode(elem);
                    } else if (typeof elem === "string") {
                        elem = elem.replace(rxhtmlTag, fcloseTag);
                        var tag = (rtagName.exec(elem) || ["", ""])[1].toLowerCase(),
                            wrap = wrapMap[tag] || wrapMap._default,
                            depth = wrap[0],
                            div = context.createElement("div");
                        div.innerHTML = wrap[1] + elem + wrap[2];
                        while (depth--) {
                            div = div.lastChild;
                        }
                        if (!jQuery.support.tbody) {
                            var hasBody = rtbody.test(elem),
                                tbody = tag === "table" && !hasBody ? div.firstChild && div.firstChild.childNodes : wrap[1] === "<table>" && !hasBody ? div.childNodes : [];
                            for (var j = tbody.length - 1; j >= 0; --j) {
                                if (jQuery.nodeName(tbody[j], "tbody") && !tbody[j].childNodes.length) {
                                    tbody[j].parentNode.removeChild(tbody[j]);
                                }
                            }
                        }
                        if (!jQuery.support.leadingWhitespace && rleadingWhitespace.test(elem)) {
                            div.insertBefore(context.createTextNode(rleadingWhitespace.exec(elem)[0]), div.firstChild);
                        }
                        elem = jQuery.makeArray(div.childNodes);
                    }
                    if (elem.nodeType) {
                        ret.push(elem);
                    } else {
                        ret = jQuery.merge(ret, elem);
                    }
                });

    mark, 24 Июля 2011

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

    +975

    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
    switch (Game1.mus)
                {
                    case false: sb.Draw(disabled, new Vector2(ScrW - 256, 90), Color.White); break;
                    case true: sb.Draw(enabled, new Vector2(ScrW - 256, 90), Color.White); break;
                }
                
                switch (Game1.bloooom)
                {
                    case false: sb.Draw(disabled, new Vector2(ScrW - 256, 180), Color.White); break;
                    case true: sb.Draw(enabled, new Vector2(ScrW - 256, 180), Color.White); break;
                }
                
                switch (Game1.part)
                {
                    case false: sb.Draw(disabled, new Vector2(ScrW - 256, 270), Color.White); break; //420
                    case true: sb.Draw(enabled, new Vector2(ScrW - 256, 270), Color.White); break;
                }
                
                switch (Game1.eff)
                {
                    case false: sb.Draw(disabled, new Vector2(ScrW - 256, 360), Color.White); break; //510
                    case true: sb.Draw(enabled, new Vector2(ScrW - 256, 360), Color.White); break;
                }
                switch (Game1.shad)
                {
                    case false: sb.Draw(disabled, new Vector2(ScrW - 256, 450), Color.White); break; 
                    case true: sb.Draw(enabled, new Vector2(ScrW - 256, 450), Color.White); break;
                }

    Оттуда же, откуда и #5199. Случайно обнаружил...

    RaZeR, 24 Июля 2011

    Комментарии (14)
  10. JavaScript / Говнокод #7327

    +161

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    if (window.ActiveXObject) window.ie = window[window.XMLHttpRequest ? 'ie7' : 'ie6'] = true;
    else if (document.childNodes && !document.all && !navigator.taintEnabled) window.webkit = window[window.xpath ? 'webkit420' : 'webkit419'] = true;
    else if (document.getBoxObjectFor != null) window.gecko = true;
    var isIE = (navigator.appVersion.indexOf("MSIE") != -1) ? true : false;
    var isWin = (navigator.appVersion.toLowerCase().indexOf("win") != -1) ? true : false;
    var isOpera = (navigator.userAgent.indexOf("Opera") != -1) ? true : false;

    mark, 24 Июля 2011

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