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

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

    +4

    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
    #include <stdio.h>
    #include <string>
    
    const struct FooAgeProperty {} age;
    const struct FooNameProperty {} name;
    
    template <typename T>
    struct FooPropertyAssignment {
    	FooPropertyAssignment(T* prop): prop(prop) { }
    
    	T* prop;
    };
    
    struct years {
    	int i;
    
    	years& operator=(FooPropertyAssignment<int> fpa) {
    		*fpa.prop = i;
    		return *this;
    	}
    };
    
    struct nam {
    	std::string s;
    
    	nam& operator=(FooPropertyAssignment<std::string> fpa) {
    		*fpa.prop = s;
    		return *this;
    	}
    };
    
    years operator""years(unsigned long long value) {
    	return { (int)value };
    }
    
    nam operator""_(const char* value, size_t) {
    	return { value };
    }
    
    struct NegativeFoo {
    	NegativeFoo(int* age, std::string* name): age(age), name(name) {}
    
    	int* age;
    	std::string* name;
    };
    
    FooPropertyAssignment<int> operator<(FooAgeProperty fap, NegativeFoo nfoo) {
    	return FooPropertyAssignment<int>(nfoo.age);
    }
    
    FooPropertyAssignment<std::string> operator<(FooNameProperty fnp, NegativeFoo nfoo) {
    	return FooPropertyAssignment<std::string>(nfoo.name);
    }
    
    struct Foo;
    Foo* nasty_global_variable;
    
    struct Foo {
    	Foo() {
    		nasty_global_variable = this;
    	}
    
    	NegativeFoo operator-() {
    		return NegativeFoo(&age, &name);
    	}
    
    	int age;
    	std::string name;
    };
    
    struct to_string {
    	struct foo {
    		foo(int (*)(const char*, ...)) {
    			printf(".old years %d am I and %s is name My\n", nasty_global_variable->age, nasty_global_variable->name.c_str());
    		}
    	};
    };
    
    int main() {
    	Foo foo;
    	5years = age<-foo;
    	"Billy"_ = name<-foo;
    	(to_string::foo)printf;
    }

    https://www.reddit.com/r/ProgrammerHumor/comments/acv2og/just_wrote_my_first_program_in_c/

    Nyamka, 06 Января 2019

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

    +1

    1. 1
    2. 2
    3. 3
    Знаете ли Вы, что ReadPrivateProfileString игнорирует закрывающую квадратную скобку в названии секции?
    
    [ThereAreValidSectionName

    Куд-куд-кудат-куд-куд!

    3oJloTou_neTyx, 05 Января 2019

    Комментарии (4)
  4. Python / Говнокод #25280

    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
    while True:
        prev_word = next_word
        if next_word.is_empty():
            next_word = random.choice(words)
        else:
            next_word = chain.get_next_word(next_word.root, lambda: Text.Word(''))
    
        suffix = suffix_chain.get_next_word((prev_word.suffix, next_word.root), lambda: '')
        if len(suffix) == 0:
            suffix = next_word.suffix
    
        punct = punct_chain.get_next_word(next_word.root, lambda: '')
    
        if len(output_words) == 0 or output_words[-1].is_ending_word():
            res_word = Text.PunctedWord(next_word.root.capitalize(), suffix, punct)
        else:
            res_word = Text.PunctedWord(next_word.root, suffix, punct)
    
        output_words += [res_word] 
        generated_chars += len(res_word)
        if chars_max_count > 0 and generated_chars > chars_max_count:
            break
        if words_max_count > 0 and len(output_words) > words_max_count:
            break

    Вореции. Генерации. Кобенации. Теперь в энтерпрайз почти ООП-стиле!
    s: https://github.com/gost-gk/vorec-enterprise

    gost, 05 Января 2019

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

    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
    import java.io.File
    import java.io.FileReader
    
    fun main(args: Array<String>) {
        val text = getText("Input line")
        val fileName = getText("Input file name")
    
        val mode = getInt("Input mode: 1 for rewrite, 2 for append", 1, 2)
    
        doAction(mode, text, fileName)
    }
    
    fun doAction(mode: Int, text : String, fileName : String) {
        val file = File(fileName)
       when(mode) {
           1 -> file.writeText(text)
           2 -> file.appendText(text)
       }
    }
    
    fun getInt(message: String, min : Int, max: Int) : Int {
    
        var buffer : Int?
    
        do {
            print(message)
            buffer = readLine()?.toIntOrNull()
        }
        while (buffer == null || buffer !in min..max)
    
        return buffer
    }
    
    fun getText(message : String) : String {
        print(message)
        return readLine() ?: ""
    }

    Решил добавить немного говнокода на Kotlin

    Tryff, 29 Декабря 2018

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

    +2

    1. 1
    2. 2
    3. 3
    4. 4
    СообщениеСМС = Перечисления.СостоянияСообщенияSMS.Исходящее;
    		Для каждого СообщениеСМС Из СообщениеSMS.Услуги Цикл
    			СообщениеСМС.СостояниеСообщения = Перечисления.СостоянияСообщенияSMS.Исходящее;
    		КонецЦикла;

    1С:Медицина. Поликлинка

    gk-5ccd112a, 21 Декабря 2018

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

    +2

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    ТекЧас = Строка(Час(Дата2));
    ТекЧас = Прав("00" + ТекЧас, 2);
    ТекМин = Строка(Минута(Дата2));
    ТекМин = Прав("00" + ТекМин, 2);
    ТекВремя = ТекЧас + ":" + ТекМин;

    Это способ получить время в формате "чч:мм" из даты и времени (переменная Дата2).
    Заменяется этим:
    ТекВремя = Формат(Дата2, "ДФ=hh:mm");

    VladC, 21 Декабря 2018

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

    0

    1. 1
    https://www.theverge.com/2018/12/4/18125238/microsoft-chrome-browser-windows-10-edge-chromium

    Chromium победил

    Her, 05 Декабря 2018

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

    +1

    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
    // HooksList.h
    #define PPCAT_NX(A, B) A ## B
    #define PPCAT(A, B) PPCAT_NX(A, B)
    
    #ifdef HOOKS_DEFS
        using namespace NtStructs;
        #define API_HOOK_DEF(module_name, hook_name, return_type, enabled, ...) \
            typedef return_type(WINAPI *PPCAT(hook_name, _ptr))(__VA_ARGS__); \
            return_type WINAPI PPCAT(hook_name, _hook)(__VA_ARGS__); \
            extern PPCAT(hook_name, _ptr) PPCAT(hook_name, _orig);
    #elif defined(HOOKS_LIST)
        #define API_HOOK_DEF(module_name, hook_name, return_type, enabled, ...) \
            {module_name, #hook_name, (LPVOID)PPCAT(hook_name, _hook), (LPVOID*)&PPCAT(hook_name, _orig), enabled},
    #elif defined(HOOKS_TYPES_DEF)
        using namespace NtStructs;
        #define API_HOOK_DEF(module_name, hook_name, return_type, enabled, ...) \
            typedef return_type(WINAPI *PPCAT(hook_name, _ptr))(__VA_ARGS__); \
            return_type WINAPI PPCAT(hook_name, _hook)(__VA_ARGS__);
    #elif defined(ORIGINAL_FUNCTIONS_TABLE_DEF)
        #define API_HOOK_DEF(module_name, hook_name, return_type, enabled, ...) \
            PPCAT(hook_name, _ptr) hook_name;
    #elif defined(ORIGINAL_FUNCTIONS_TABLE_FILL)
        #define API_HOOK_DEF(module_name, hook_name, return_type, enabled, ...) \
            (ORIGINAL_FUNCTIONS_TABLE_NAME).hook_name = PPCAT(hook_name, _orig);
    #else
        #define API_HOOK_DEF(...)
    #endif
    
    // NtCreateFile
    API_HOOK_DEF(L"ntdll", NtCreateFile, NTSTATUS, true,
                 PHANDLE            FileHandle,
                 ACCESS_MASK        DesiredAccess,
                 POBJECT_ATTRIBUTES ObjectAttributes,
                 PIO_STATUS_BLOCK   IoStatusBlock,
                 PLARGE_INTEGER     AllocationSize,
                 ULONG              FileAttributes,
                 ULONG              ShareAccess,
                 ULONG              CreateDisposition,
                 ULONG              CreateOptions,
                 PVOID              EaBuffer,
                 ULONG              EaLength)
    
    // NtDeleteFile
    API_HOOK_DEF(L"ntdll", NtDeleteFile, NTSTATUS, true,
                 POBJECT_ATTRIBUTES ObjectAttributes)
    // И так далее
    
    // В .cpp:
    static HookEntry hookEntries[] = {
    #define HOOKS_LIST
    #include "HooksList.h"
    #undef HOOKS_LIST
    };
    
    
    // ...
    static OriginalFunctions originalFuncsTable;
    #define ORIGINAL_FUNCTIONS_TABLE_FILL 1
    #define ORIGINAL_FUNCTIONS_TABLE_NAME originalFuncsTable
    #include "HooksList.h"
    #undef ORIGINAL_FUNCTIONS_TABLE_NAME
    #undef ORIGINAL_FUNCTIONS_TABLE_FILL

    Мокросы!..

    gost, 30 Ноября 2018

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

    −4

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    12. 12
    начало пхп прог уннамед
    
    подключить "пхп модуль 1.0"
    
    доллар целое а = 4
    доллар целое б = 2
    
    печать сум доллар а + доллар б 2
    
    помолиться perl
    
    конец пхп прог уннамед

    Ksyrx, 28 Ноября 2018

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

    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
    #include "pch.h"
    #include <iostream>
    using namespace std;
     
    void p(int a[], int &h )
    {
      int i = 0;
      int max = 0;
      int counter = 1;
      while (counter < h)
      {
        if (a[counter] > a[max])
        {
          max = counter;
        }
        counter = counter + 1;
      }
      int min = 0;
      int counter2 = 1;
      while (counter < h)
      {
        if (a[counter] < a[min])
        {
          min = counter;
        }
        counter = counter + 1;
      }
      int kol, kol2;
      if (max > min)
      {
        if (max != min)
        {
          kol = max - min - 1;
          i = min + 1;
          cout << "Kolichestvo elementov mezdu imin i imax: " << kol << endl;
        }
        else
        {
          cout << "Kolichestvo elementov mezdu imin i imax: 0" << endl;
        }
      }
      else
      {
        if (max != min)
        {
          kol2 = min - max - 1;
          i = max + 1;
          cout << "Kolichestvo elementov mezdu imin i imax: " << kol2 << endl;
        }
        else
        {
          cout << "Kolichestvo elementov mezdu imin i imax: 0" << endl;
        }
      }
      int sum = 0;
      while (i < max)
      {
        sum = sum + a[i];
        i++;
      }
      cout << "Summa elementov mezdu imin i imax: " << sum << endl;
    }
     
     
    int main()
    {
      int h;
      cout << "Vvedite razmer massiva: ";
      cin >> h;
      int *a = new int[h];
      for (int i = 0; i < h; i++)
        cin >> a[i];
      p(a, h);
      delete[] a;
      return 0;
    }

    Увековеченный Говнокод Нама, моего друга из Вьетнама (УГК)

    ugk, 26 Ноября 2018

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