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

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

    +70

    1. 1
    qDebug() << QString("%1-%2").arg("%1").arg("foo");

    LispGovno, 19 Апреля 2014

    Комментарии (37)
  3. Pascal / Говнокод #15627

    +81

    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
    program matr;
    uses
       crt;
    var
        mas:array [1..100] of integer;
        i,n,imin,imax,min,max,razn:integer;
    begin
    clrscr;
    imax:=1;
    imin:=1;
    randomize;
    write('Введите количество элементов: ');
    readln(n);
    for i:=1 to n do
     begin
      mas[i]:=random(10)-5;
      write(mas[i]:4);
      if mas[i]>mas[imax] then
      begin
      imax:=i;
      end
      else
      if (mas[i]<mas[imin]) then
      begin
      imin:=i;
      end;
      end;
    writeln;
    writeln('MAX[',imax,']:=',mas[imax]);
    writeln('MIN[',imin,']:=',mas[imin]);
    razn:=mas[imax]+mas[imin];
    writeln('Сумма MAX и MIN:=',razn);
     end.

    Написано by "ТАМБОВСКИЙ ВОЛК. Профессионал".
    Знатное говнецо нынче пишут "профессионалы".
    http://www.programmersforum.ru/showthread.php?t=98747

    gost, 31 Марта 2014

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

    +100

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    <?php
    $a=0;
    $b=null;
     
    echo $a==$b?1:0; //1

    Разрабы пхп троллят.

    Vasiliy, 11 Февраля 2014

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

    +70

    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
    public class ImportException extends Exception {
    
    	public static final int NOT_CRITICAL = 1;
    	public static final int CRITICAL = 2;
    
    	private int criticality = NOT_CRITICAL;
    
    	public ImportException(String message) {
    		this.message = message;
    	}
    
    	/**
    	 * С критичностью
    	 * @param message
    	 * @param criticality
    	 */
    	public ImportException(String message, int criticality) {
    		this.message = message;
    		this.criticality = criticality;
    	}
    
    	public int getCriticality() {
    		return criticality;
    	}
    
    	public void setCriticality(int criticality) {
    		this.criticality = criticality;
    	}
    }

    изобретение типа bool

    evg_ever, 04 Февраля 2014

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

    +21

    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
    template <int N>
    void Ololo ()
    {
    	var
    		i : integer;
    	begin
    		for i := 0 to N-1 do begin
    			WriteLn(i, ' ');
    		end;
    	end;
    }
    
    int main () 
    {
    	return 0;
    }
    
    Compiling...
    Test.cpp
    Linking...
    
    Build log was saved at "file://c:\Users\TarasB\Documents\Visual Studio Projects\Test\Debug\BuildLog.htm"
    Test - 0 error(s), 0 warning(s)
    
    
    ---------------------- Done ----------------------
    
        Build: 1 succeeded, 0 failed, 0 skipped

    MSVS2003

    TarasB, 15 Января 2014

    Комментарии (37)
  7. Java / Говнокод #14254

    +83

    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
    // java.io.FilterOutputStream
    public void close() throws IOException {
        try {
            flush();
        } catch (IOException ignored) {
        }
        out.close();
    }
    
    // тестовый код
    try (OutputStream os = new BufferedOutputStream(new FileOutputStream("/tmp/little_virtual_fs/1.txt"))) {
        byte[] buf = new byte[2028544];
        os.write(buf, 0, 2028544); // максимальный размер файла, который влезает на нашу фс
        os.write(buf, 0, 5); // и еще немножко
        //os.flush();
    }

    А сейчас, на арене нашего цирка - очередная жабопроблема!

    Как думаете, каков результат выполнения тестовой программы?

    Запишет 2028549 байт? Хрен там, места маловато.
    Выдаст IOException на write()? Хрен там, буферизация.
    Выдаст IOException на close()? Хрен там, его сожрала реализация FilterOutputStream.

    Результат: файл не дописался, исключения нет.
    Решение: всегда дергать flush() перед close() самому или не юзать буферизованный поток.

    bormand, 21 Декабря 2013

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

    +166

    1. 1
    if (substr(json_encode($row['list']), 0, 1) == '[') {

    Такой вот аналог is_array()

    Lowezar, 17 Декабря 2013

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

    +13

    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
    typedef std::queue<Msg> Queue;    
        
    
    struct SharedQueue
    {
        private:
            Queue m_queue;
            boost::mutex m_mux;
            boost::condition_variable m_condvar;    
        private:
            struct is_empty
            {
                Queue& queue;
                is_empty( Queue& q):
                    queue(q)
                {
                }
    
                bool operator()() const
                {
                    return !queue.empty();
                }
            };
        public:
            void push(const Msg& msg)
            {
                boost::mutex::scoped_lock lock(m_mux);
                m_queue.push( msg);
                m_condvar.notify_one();
            }
    
            bool try_pop( Msg& msg, Kind kind)
            {
                boost::system_time const timeout=boost::get_system_time()+ boost::posix_time::milliseconds( 30000);
                boost::mutex::scoped_lock lock( m_mux);
                if ( m_condvar.timed_wait( lock, timeout, is_empty( m_queue)))
                {
                    if( !m_queue.empty() && m_queue.front().kind == kind)
                    {
                        msg = m_queue.front();
                        m_queue.pop();
                        return true;
                    }
                }
                return false;
            }
    };

    Это ж пипец, дорогие товарищи...

    blackhearted, 29 Ноября 2013

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

    +130

    1. 1
    List<KeyValuePair<string, string>> documentList = GetList();

    использование списка пар ключ-значение вместо словаря (Dictionary<string, string>)

    mozg_raka, 22 Ноября 2013

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

    +80

    1. 1
    new

    TarasB, 13 Ноября 2013

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