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

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

    −2

    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
    NTSTATUS resize(size_t new_capacity)
    {
        NT_ASSERT(new_capacity >= m_size);
        if constexpr (std::is_pod_v<T>) {
            T *new_array = static_cast<T*>(KReallocate(m_size, new_capacity, sizeof(T), m_array, POOL, TAG));
            if (!new_array) {
                return STATUS_NO_MEMORY;
            }
            m_capacity = new_capacity;
            m_array = new_array;
        } else {
            T *new_array = static_cast<T*>(KAllocate(new_capacity, sizeof(T), POOL, TAG));
            if (!new_array) {
                return STATUS_NO_MEMORY;
            }
             for (size_t i = 0; i < m_size; i++) {
                new (&new_array[i]) T(std::move(m_array[i]));
                m_array[i].~T();
            }
            KmdfDeallocate(m_array, TAG);
            m_capacity = new_capacity;
            m_array = new_array;
        }
    
        return STATUS_SUCCESS;
    }

    gost, 17 Сентября 2018

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

    −1

    1. 1
    2. 2
    Давайте ругать "Windows"
    https://habr.com/post/418087/

    Syoma, это кокраз то, о чем ты писал: https://habr.com/post/418087/#comment_18916563

    guestinxo, 25 Июля 2018

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

    0

    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
    /* Разработчик  http://webkiev.com/  Тарас КТЛ(Кучинский Тарас Леонидович)  г.Киев ул. Заболотного 26 */
    
    if($count_tovar!=0){
     $count_filtr=count($shop_m_tovar[0]);
    $i=0;while ($i < $count_tovar) {$ii=0; while ($ii < $count_filtr){$shop_filtr[$ii][$i]=$shop_m_tovar[$i][$ii];$ii++;}$i++;}
    if($tovar_sort=="1"){/*сортировка по возрастанию по цене*/
    array_multisort(
    $shop_filtr[6],$shop_filtr[7],$shop_filtr[8],$shop_filtr[9],
    $shop_filtr[10],$shop_filtr[11],$shop_filtr[12],$shop_filtr[13],$shop_filtr[14],$shop_filtr[15],$shop_filtr[16],$shop_filtr[17],$shop_filtr[18],$shop_filtr[19],
    $shop_filtr[20],$shop_filtr[21],$shop_filtr[22],$shop_filtr[23],$shop_filtr[24],$shop_filtr[25],$shop_filtr[26],$shop_filtr[27],$shop_filtr[28],$shop_filtr[29],
    $shop_filtr[30],$shop_filtr[31],$shop_filtr[32],$shop_filtr[33],$shop_filtr[34],$shop_filtr[35],$shop_filtr[36],$shop_filtr[37],$shop_filtr[38],$shop_filtr[39],
    $shop_filtr[40],$shop_filtr[41],$shop_filtr[42],$shop_filtr[43],$shop_filtr[44],$shop_filtr[45],$shop_filtr[46],$shop_filtr[47],$shop_filtr[48],
    $shop_filtr[49],
    $shop_filtr[50],$shop_filtr[51],$shop_filtr[52],$shop_filtr[53],$shop_filtr[54],$shop_filtr[55],$shop_filtr[56],$shop_filtr[57],$shop_filtr[58],$shop_filtr[59],
    $shop_filtr[60],$shop_filtr[61],$shop_filtr[62],$shop_filtr[63],$shop_filtr[64],$shop_filtr[65],$shop_filtr[66],$shop_filtr[67],$shop_filtr[68],$shop_filtr[69],
    $shop_filtr[70],
    $shop_filtr[0],$shop_filtr[1],$shop_filtr[2],$shop_filtr[3],$shop_filtr[4],$shop_filtr[5]
    );
    }
    if($tovar_sort=="2"){/*сортировка на убывание по цене*/
    array_multisort(
    $shop_filtr[6],SORT_DESC, $shop_filtr[7],$shop_filtr[8],$shop_filtr[9],
    $shop_filtr[10],$shop_filtr[11],$shop_filtr[12],$shop_filtr[13],$shop_filtr[14],$shop_filtr[15],$shop_filtr[16],$shop_filtr[17],$shop_filtr[18],$shop_filtr[19],
    $shop_filtr[20],$shop_filtr[21],$shop_filtr[22],$shop_filtr[23],$shop_filtr[24],$shop_filtr[25],$shop_filtr[26],$shop_filtr[27],$shop_filtr[28],$shop_filtr[29],
    $shop_filtr[30],$shop_filtr[31],$shop_filtr[32],$shop_filtr[33],$shop_filtr[34],$shop_filtr[35],$shop_filtr[36],$shop_filtr[37],$shop_filtr[38],$shop_filtr[39],
    $shop_filtr[40],$shop_filtr[41],$shop_filtr[42],$shop_filtr[43],$shop_filtr[44],$shop_filtr[45],$shop_filtr[46],$shop_filtr[47],$shop_filtr[48],
    $shop_filtr[49],
    $shop_filtr[50],$shop_filtr[51],$shop_filtr[52],$shop_filtr[53],$shop_filtr[54],$shop_filtr[55],$shop_filtr[56],$shop_filtr[57],$shop_filtr[58],$shop_filtr[59],
    $shop_filtr[60],$shop_filtr[61],$shop_filtr[62],$shop_filtr[63],$shop_filtr[64],$shop_filtr[65],$shop_filtr[66],$shop_filtr[67],$shop_filtr[68],$shop_filtr[69],
    $shop_filtr[70],
    $shop_filtr[0],$shop_filtr[1],$shop_filtr[2],$shop_filtr[3],$shop_filtr[4],$shop_filtr[5]
    );
    }
    $i=0;while ($i < $count_tovar) {$ii=0; while ($ii < $count_filtr) {$shop_m_tovar[$i][$ii]=$shop_filtr[$ii][$i];$ii++;}$i++;}
    }

    Сортировка товаров на чистом коде

    brevis, 16 Июля 2018

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

    0

    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
    <!DOCTYPE html>
    <html>
        <head>
            <title>Why is he always talking about that damm movie?</title>
        </head>
        
    <img src="https://cdn.shopify.com/s/files/1/0064/7532/products/poster-war-games-1983-regular-2_1024x1024.jpg?v=1455775393" width="350" height="250">
    <br>
    <p>Wargames 1983</p>
    <br>
    <p>from: https://en.wikipedia.org/wiki/WarGames</p>
    <p>The film follows David Lightman, a young hacker who unwittingly accesses WOPR (War Operation Plan Response), a United States military supercomputer originally programmed to predict possible outcomes of nuclear war. Lightman gets WOPR to run a nuclear war simulation, believing it to be a computer game. The computer, now tied into the nuclear weapons control system and unable to tell the difference between simulation and reality, attempts to start World War III.
    </p>
    <img src="http://cdn3-www.comingsoon.net/assets/uploads/2015/10/wargames-1.jpg" width="350" height="200">
    <br>
    <p>The computer stages a massive Soviet first strike with hundreds of missiles, submarines, and bombers. Believing the attack to be genuine, NORAD prepares to retaliate. Falken (Inventor/Programmer) and David convince military officials to cancel the second strike and ride out the attack. WOPR tries to launch the missiles itself, however, using a brute-force attack to obtain the launch code. Without humans in the control centers as a safeguard, the computer will trigger a mass launch. All attempts to log in and order to cancel the countdown fail, and all weapons will launch if the computer is disabled.</p>
        
    <br>    
        <img src="http://oliversmith.cc/wp-content/uploads/2014/11/Screen-Shot-2014-11-26-at-14.17.30-e1417011526324-640x469.png" width="350" height="200">
    <p>Falken and David direct the computer to play tic-tac-toe against itself. This results in a long string of draws, forcing the computer to learn the concept of futility and no-win scenarios. WOPR obtains the missile code, but before launching, it cycles through all the nuclear war scenarios it has devised, finding they, too, all result in stalemates. Having discovered the concept of mutual assured destruction ("WINNER: NONE"), the computer tells Falken that it has concluded that nuclear war is "a strange game" in which "the only winning move is not to play." WOPR relinquishes control of NORAD and the missiles and offers to play "a nice game of chess."</p>
        
      </body>  
    </html>

    Ржунимагу. Этот говно код набрал 25 лайков а нормальный мой код калькулятора во вкладке рядом 0. Куда катится мир...

    Arduino, 02 Июля 2018

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

    0

    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
    class NTPTime {
    public:
    	static NTPTime getInvalidTime() { NTPTime t; t.setInvalid(); return t; }
    
    public:
    	NTPTime() : m_Time(0) {}
    	NTPTime(const uint64_t time) : m_Time(time) {}
    	NTPTime(const uint32_t sec, const uint32_t frac)
    	  : m_Time(0)
    	{
    		this->set(sec, frac);
    	}
    
    	NTPTime(const boost::posix_time::ptime& timestamp);
    
    public: // Assignment operators
    	NTPTime& operator=(const uint64_t u) { m_Time = u; return *this; }
    	NTPTime& operator+= (const NTPTime& Q) { m_Time += Q.m_Time; return *this; }
    	NTPTime& operator-= (const NTPTime& Q) { m_Time -= Q.m_Time; return *this; }
    
    public: // Cast operators
    	operator uint64_t() { return this->m_Time; }
    
    public: // comparison operators
    	bool operator==(const NTPTime& other) const { return (m_Time == other.m_Time); }
    	bool operator!=(const NTPTime& other) const { return (m_Time != other.m_Time); }
    	bool operator>=(const NTPTime& other) const { return (m_Time >= other.m_Time); }
    	bool operator>(const NTPTime& other) const { return (m_Time > other.m_Time); }
    	bool operator<=(const NTPTime& other) const { return (m_Time <= other.m_Time); }
    	bool operator<(const NTPTime& other) const { return (m_Time < other.m_Time); }
    
    public: // arithmetic operators
    	NTPTime operator+(const NTPTime& other) const
    	{
    		NTPTime result = *this;
    		result += other;
    		return result;
    	}
    
    	NTPTime operator-(const NTPTime& other) const
    	{
    		NTPTime result = *this;
    		result -= other;
    		return result;
    	}
    
    public:
    	uint32_t getSeconds() const { return ((uint32_t)(m_Time >> 32));}
    	uint32_t getFracSeconds() const { return ((uint32_t)(m_Time & 0xFFFFFFFF));}
    	uint32_t getMilliseconds() const { const uint64_t t = 1000*m_Time ; return (uint32_t)((t>>32)&0xFFFFFFFF);}
    	uint32_t getMicroseconds() const { const uint64_t t = 125*m_Time/536871; return (uint32_t)(t&0xFFFFFFFF);}
    	void getTime_s_us(uint32_t& sec, uint32_t& us) const { sec = getSeconds(); us = getFracSeconds()/4295;}
    	uint64_t getTime(void) const {return m_Time;}
    
    public:
    	/// set the time in seconds and microseconds (micros: 0..1000 0000)
    	///This routine uses the factorization: 2^32/10^6 = 4096 + 256 - 1825/32
    	void setTime_s_us(const uint32_t sec, const uint32_t us) { m_Time = ((uint64_t)sec<<32) | ((us<<12)-((us*1852)>>5)+(us<<8));}
    
    	void set(const uint64_t& u) {m_Time = u;}
    	void set(const uint32_t sec, const uint32_t frac)
    	{
    		m_Time = sec;
    		m_Time = m_Time<<32;
    		m_Time |= frac;
    	}
    
    	void setInvalid() { m_Time = uint64_t(NOT_A_DATE_TIME) << 32; }
    
    	/// 2^32/10^6 = 4096 + 256 - 1825/32
    	void setMicroseconds(const uint32_t u) { const uint64_t t = ((uint64_t)u * 1825) >> 5; m_Time = ((uint64_t)u << 12) + ((uint64_t)u << 8) - t;}
    	void setMicroseconds(const uint64_t u) { const uint64_t t = (u * 1825) >> 5; m_Time = (u << 12) + (u << 8) - t;}
    	void setMilliseconds(const uint32_t u) { m_Time = (uint64_t)u * 536870912 / 125;}
    	void addMilliseconds(const uint32_t u) { NTPTime t; t.setMilliseconds(u); *this += t;}
    	void addMicroseconds(const uint32_t u) { NTPTime t; t.setMicroseconds(u); *this += t;}
    
    protected:
    	static double round(const double v);
    
    private:
    	static const double secondFractionNTPtoNanoseconds;
    	static const double nanosecondsToSecondFractionNTP;
    	static const uint32_t NOT_A_DATE_TIME;
    	static const uint64_t NOT_A_DATE_TIME64;
    	static const boost::posix_time::ptime m_epoch;
    
    protected:
    	uint64_t m_Time; ///< NTP time in 1/2^32 seconds (~233 ps)
    }; // NTPTime

    Чуть г-на и несколько комментов удалил, чтоб влезло. Чтоб понятно было, m_Time хранит время в единицах 1/2^32 сек.

    elapidae, 22 Марта 2018

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

    +2

    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
    #include "stdafx.h"
    #include<iostream>
    #include<fstream>
    #include<string>
    #include<map>
    #include<iomanip>
    using namespace std;
    int main()
    {
    	string word;
    	setlocale(LC_ALL, "Russian");
    	char s[80];
    	fstream inOut;
    	multimap<string, int>my;
    	multimap<string, int>::iterator it;
    	inOut.open("text.txt", ios::in);
    	for (int i = 1; i < 40; i++) {
    		inOut.getline(s, 256);
    		char* pch;
    		pch = strtok(s, " ,-:;");
    		while (pch != NULL) {
    			word = string(pch);
    			my.insert(pair <string, int>(pch, i));
    			//cout << pch <<'\t'<<i<< endl;
    			pch = strtok(NULL, " ,-:");
    		}
    	}
    		inOut.close();
    	//cout << s;
    		for (it = my.begin(); it != my.end(); it++) {
    			cout.width(25);
    			cout << (*it).first <<setw(5) << (*it).second  << endl;
    		}
    	
    	
    	system("pause");
        return 0;
    }

    Берёт из текста строки и сортирует в алфавитном порядке

    ArthurMakaev, 19 Марта 2018

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

    −1

    1. 1
    2. 2
    3. 3
    4. 4
    // Read option name (can contain spaces)
         while (is >> token && token != "value")
    -        name += string(" ", name.empty() ? 0 : 1) + token;
    +        name += (name.empty() ? "" : " ") + token;

    terminate called after throwing an instance of 'std::length_error'
    what(): basic_string::_M_create


    Replacing string(" ", name.empty() ? 0 : 1) with (name.empty() ? "" : " ") and the same in the while() loop for value fixes the problem (for me).

    Does anyone know if "string(" ", 0)" is invalid C++ ?

    Кресты такие кресты.

    3.14159265, 18 Февраля 2018

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

    0

    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
    https://www.google.de/search?q=случайное+фио
    https://names-generator.ru/
    
        Кудряшова Екатерина Митрофановна
        Ширяев Константин Куприянович
        Тетерина Венера Максимовна
        Калинина Лора Михаиловна
        Осипова Кира Валентиновна
        Абрамова Ираида Григорьевна
        Игнатьев Эдуард Николаевич
        Мухина Оксана Филатовна
        Дьячков Вадим Вячеславович
        Мишин Владлен Лукьевич

    Не разу еще не встречал генератор, который бы учитывал частотное распределение имен.

    syoma, 15 Февраля 2018

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

    0

    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
    function checkAnswer(lastId, connectionString, success, unsuccess, installationNumber) {
      var result;
      for(var i=0;i<3*15/*15min*/;i++) {
        Delay(periodCheckingComponentsInstalled, "Waiting components to be installed");
        result = getDataFromDB(connectionString, lastId);
        var k = [];
        for(var i=0;i<success.length; i++) {
          k.push(false);
        }
        
        for(var i=0;i<success.length;i++) {
          if ((success[i] == "RemoteSuccess") ||  (success[i] == "RemoteUnSuccess")) {
            k[i] = true;
            break;
          }
          else {
            for(var j=0;j<result.length ; j++) {
              if (result[j].length > 40) {
                k[i] = includeArray(result, success[i]);//40 symb
                if (includeArray(result, unsuccess[i])) Log.Error("error while installing, number installation = " + installationNumber);
              }
            }
          }
        }
        var bool = true;
        for (var i=0;i<success.length; i++) {
          bool = bool&&k[i];
        } 
        if (bool) return true; else continue;
        return false;
      }
    }

    Остался скрипт от тестировщика. Блядь, и такого там с мегабайт.

    fluttr, 13 Ноября 2017

    Комментарии (17)
  11. VisualBasic / Говнокод #23423

    0

    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 Function DecodName(ByVal ind As Integer) As String
            ''перекодування назви місяця
            Select Case ind
                Case 1
                    Return "Січень"
                Case 2
                    Return "Лютий"
                Case 3
                    Return "Березень"
                Case 4
                    Return "Квітень"
                Case 5
                    Return "Травень"
                Case 6
                    Return "Червень"
                Case 7
                    Return "Липень"
                Case 8
                    Return "Серпень"
                Case 9
                    Return "Вересень"
                Case 10
                    Return "Жовтень"
                Case 11
                    Return "Листопад"
                Case 12
                    Return "Грудень"
                Case Else
                    Return ""
            End Select
        End Function

    Мои глаза...

    vova94, 17 Октября 2017

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