1. Pascal / Говнокод #27528

    +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
    #!/usr/bin/env instantfpc
    
    program PrintCharTable;
    
    const
    	space = ' '; { }
    	point = '.'; {.}
    	caret = '^'; {^}
    	vline = '|'; {│}
    	hline = '-'; {─}
    	cross = '+'; {┼}
    	hex_0 = ord('0');
    	hex_a = ord('A')-10;
    
    function tohex(d: integer): char;
    begin
    	if d < 10 then
    		tohex := chr(d+hex_0)
    	else
    		tohex := chr(d+hex_a)
    end;
    
    var
    	i, j: integer;
    	code: integer;
    
    begin
    	write(space, space, vline);
    	for i := 0 to 15 do
    		write(space, point, tohex(i));
    	writeln;
    
    	write(hline, hline, cross);
    	for i := 0 to 15 do
    		write(hline, hline, hline);
    	writeln;
    	
    	for i := 0 to 15 do begin
    		write(tohex(i), point, vline);
    		for j := 0 to 15 do begin
    			code := i * 16 + j;
    			if code < 32 then
    				write(space, caret, chr(code+64))
    			else if code = 127 then
    				write(space, caret, chr(code-64))
    			else
    				write(space, space, chr(code))
    		end;
    		writeln
    	end
    end.
    
    {
    $ ./print_ascii.pas | iconv -f koi8-r
      | .0 .1 .2 .3 .4 .5 .6 .7 .8 .9 .A .B .C .D .E .F
    --+------------------------------------------------
    0.| ^@ ^A ^B ^C ^D ^E ^F ^G ^H ^I ^J ^K ^L ^M ^N ^O
    1.| ^P ^Q ^R ^S ^T ^U ^V ^W ^X ^Y ^Z ^[ ^\ ^] ^^ ^_
    2.|     !  "  #  $  %  &  '  (  )  *  +  ,  -  .  /
    3.|  0  1  2  3  4  5  6  7  8  9  :  ;  <  =  >  ?
    4.|  @  A  B  C  D  E  F  G  H  I  J  K  L  M  N  O
    5.|  P  Q  R  S  T  U  V  W  X  Y  Z  [  \  ]  ^  _
    6.|  `  a  b  c  d  e  f  g  h  i  j  k  l  m  n  o
    7.|  p  q  r  s  t  u  v  w  x  y  z  {  |  }  ~ ^?
    8.|  ─  │  ┌  ┐  └  ┘  ├  ┤  ┬  ┴  ┼  ▀  ▄  █  ▌  ▐
    9.|  ░  ▒  ▓  ⌠  ■  ∙  √  ≈  ≤  ≥     ⌡  °  ²  ·  ÷
    A.|  ═  ║  ╒  ё  ╓  ╔  ╕  ╖  ╗  ╘  ╙  ╚  ╛  ╜  ╝  ╞
    B.|  ╟  ╠  ╡  Ё  ╢  ╣  ╤  ╥  ╦  ╧  ╨  ╩  ╪  ╫  ╬  ©
    C.|  ю  а  б  ц  д  е  ф  г  х  и  й  к  л  м  н  о
    D.|  п  я  р  с  т  у  ж  в  ь  ы  з  ш  э  щ  ч  ъ
    E.|  Ю  А  Б  Ц  Д  Е  Ф  Г  Х  И  Й  К  Л  М  Н  О
    F.|  П  Я  Р  С  Т  У  Ж  В  Ь  Ы  З  Ш  Э  Щ  Ч  Ъ
    }

    Печатает таблицу нужной кодировки. Пример использования в комменте после end.

    Threadwalker, 20 Июля 2021

    Комментарии (40)
  2. JavaScript / Говнокод #27527

    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
    class XFoo {
        pin: number;
        buf: number[];
    
        constructor(k: number, l: number) {
            this.pin = k - l;
        }
    
        setPin(p: number) {
            this.pin = p;
        }
    
        getPin() {
            return this.pin;
        }
    
        init() {
            this.buf = [1, 2];
        }
    
        toString() {
            return `Foo${this.getPin()}`;
        }
    }
    
    function main() {
        let f = new XFoo(44, 2);
        let s = "" + f;
        print(s);
    }

    я вам тут хрень принес.. новая фича :)

    ASD_77, 19 Июля 2021

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

    0

    1. 1
    IT Оффтоп #103

    #73: https://govnokod.ru/27136 https://govnokod.xyz/_27136
    #74: https://govnokod.ru/27160 https://govnokod.xyz/_27160
    #75: https://govnokod.ru/27166 https://govnokod.xyz/_27166
    #76: https://govnokod.ru/27168 https://govnokod.xyz/_27168
    #77: https://govnokod.ru/27186 https://govnokod.xyz/_27186
    #78: https://govnokod.ru/27219 https://govnokod.xyz/_27219
    #79: https://govnokod.ru/27254 https://govnokod.xyz/_27254
    #80: https://govnokod.ru/27270 https://govnokod.xyz/_27270
    #81: https://govnokod.ru/27280 https://govnokod.xyz/_27280
    #82: https://govnokod.ru/27284 https://govnokod.xyz/_27284
    #83: https://govnokod.ru/27296 https://govnokod.xyz/_27296
    #84: https://govnokod.ru/27336 https://govnokod.xyz/_27336
    #85: https://govnokod.ru/27381 https://govnokod.xyz/_27381
    #86: https://govnokod.ru/27405 https://govnokod.xyz/_27405
    #87: https://govnokod.ru/27429 https://govnokod.xyz/_27429
    #88: https://govnokod.ru/27432 https://govnokod.xyz/_27432
    #89: https://govnokod.ru/27435 https://govnokod.xyz/_27435
    #90: https://govnokod.ru/27439 https://govnokod.xyz/_27439
    #91: https://govnokod.ru/27449 https://govnokod.xyz/_27449
    #92: https://govnokod.ru/27460 https://govnokod.xyz/_27460
    #93: https://govnokod.ru/27463 https://govnokod.xyz/_27463
    #94: https://govnokod.ru/27466 https://govnokod.xyz/_27466
    #95: https://govnokod.ru/27473 https://govnokod.xyz/_27473
    #96: https://govnokod.ru/27478 https://govnokod.xyz/_27478
    #97: https://govnokod.ru/27484 https://govnokod.xyz/_27484
    #98: https://govnokod.ru/27495 https://govnokod.xyz/_27495
    #99: https://govnokod.ru/27504 https://govnokod.xyz/_27504
    #100: https://govnokod.ru/27508 https://govnokod.xyz/_27508
    #101: https://govnokod.ru/27511 https://govnokod.xyz/_27511
    #102: https://govnokod.ru/27518 https://govnokod.xyz/_27518

    nepeKamHblu_nemyx, 19 Июля 2021

    Комментарии (2053)
  4. Си / Говнокод #27525

    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
    #include <stdio.h>
    #include <stdlib.h>
    #include <inttypes.h>
    
    typedef struct list list;
    
    struct list
    {
      list* next;
      uint32_t data;
    };
    
    #define ADD_LIST(ptr, val) \
    do { \
      (ptr)->next = (list *)alloca(sizeof(list)); \
      (ptr)->next->data = val; \
      (ptr)->next->next = NULL;\
    } while (0)
    
    // https://gcc.gnu.org/onlinedocs/gcc/Statement-Exprs.html
    #define INIT_LIST(val) \
    ({ \
      list *INIT_LIST = (list *)alloca(sizeof(list)); \
      INIT_LIST->data = val; \
      INIT_LIST->next = NULL; \
      INIT_LIST; \
    })
    
    
    int main(void)
    {
      list *a = INIT_LIST(5);
      ADD_LIST(a,10);
      ADD_LIST(a->next,15);
      ADD_LIST(a->next->next,20);
      ADD_LIST(a->next->next->next,25);
      ADD_LIST(a->next->next->next->next,30);
    
      for(list *ptr = a; ptr != NULL; ptr = ptr->next)
      {
        printf("%d ", ptr->data);
      }
    
      return EXIT_SUCCESS;
    }

    А можно ли в крестоговне так сделать без Сишного Препроцессора?

    j123123, 19 Июля 2021

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

    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
    using System;
     
    namespace MainNamespace
    {
        class SelectionSort
        {
            private static int FindSmallest(int[] arr)
            {
                int smallest = arr[0];
                int smallestIndex = 0;
                for (int i = 1; i < arr.Length; i++)
                {
                    if (arr[i] < smallest)
                    {
                        smallest = arr[i];
                        smallestIndex = i;
                    }
                }
                return smallestIndex;
            }
            public static int[] ArraySort(int[] arr)
            {
                int[] newArr = new int[arr.Length];
                for (int i = 0; i < arr.Length; i++)
                {
                    int smallestIndex = FindSmallest(arr);
                    int arrayBeginningIndex = i;
                    newArr[arrayBeginningIndex] = arr[smallestIndex];
                    arr[smallestIndex] = Int32.MaxValue;
                }
                return newArr;
            }
        }
        class MainClass
        {
            const int sizeOfArr = 7;
            static int FindMaxProduct(int[] arr)
            {
                int maxProduct = 1;
                int firstIndex = 0;
                int secondIndex = 1;
                int lastIndex = sizeOfArr - 1;
                int beforeLastIndex = sizeOfArr - 1 - 1;
                int beforeBeforeLastIndex = sizeOfArr - 1 - 2;
     
                if (arr[firstIndex] * arr[secondIndex] * arr[lastIndex] > arr[beforeLastIndex] * arr[beforeBeforeLastIndex] * arr[lastIndex])
                {
                    maxProduct = arr[firstIndex] * arr[secondIndex] * arr[lastIndex];
                }
                else
                    for (int i = 0; i < 3; i++)
                        maxProduct *= arr[lastIndex - i];
     
                return maxProduct;
            }
            static void Main()
            {
                int[] arr = new int[sizeOfArr] {-31, 54, -39, -34, 0, 56, 92};
                arr = SelectionSort.ArraySort(arr);
                Console.WriteLine( FindMaxProduct(arr) );
                Console.ReadKey();
            }
        }
    }

    Есть массив с целыми числами. Найти в этом массиве самое большое произведение 3 чисел и вывести в консоль.

    BelCodeMonkey, 18 Июля 2021

    Комментарии (96)
  6. Куча / Говнокод #27523

    0

    1. 1
    Тестовый Оффтоп #3

    #1: https://govnokod.ru/26373 https://govnokod.xyz/_26373
    #1: https://govnokod.ru/26611 https://govnokod.xyz/_26611
    #1: https://govnokod.ru/26824 https://govnokod.xyz/_26824
    #1: https://govnokod.ru/26850 https://govnokod.xyz/_26850
    #2: https://govnokod.ru/27102 https://govnokod.xyz/_27102

    bagrinho, 18 Июля 2021

    Комментарии (582)
  7. Куча / Говнокод #27522

    +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
    ...
    
           fun([N1, _N2], Trace) ->
                   ?assert(
                      ?strict_causality( #{?snk_kind := "Adding table to a shard", shard := _Shard, live_change := true}
                                       , #{?snk_kind := "Shard schema change"}
                                       , ?of_node(N1, Trace)
                                       )),
                   ?assert(
                      ?strict_causality( #{?snk_kind := "Shard schema change", shard := _Shard}
                                       , #{?snk_kind := "Restarting shard server", shard := _Shard}
                                       , ?of_node(N1, Trace)
                                       )),
                   %% Schema change must cause restart of the replica process and bootstrap:
                   {_, Rest} = ?split_trace_at(#{?snk_kind := "Shard schema change"}, Trace),
                   ?assert(
                      ?strict_causality( #{?snk_kind := "Restarting shard server", shard := _Shard}
                                       , #{?snk_kind := state_change, to := bootstrap}
                                       , Rest
                                       ))
           end).

    Немного galaxy-brain тестов

    CHayT, 17 Июля 2021

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

    0

    1. 1
    Пиздец-оффтоп #25

    #1: https://govnokod.ru/26503 https://govnokod.xyz/_26503
    #2: https://govnokod.ru/26541 https://govnokod.xyz/_26541
    #3: https://govnokod.ru/26583 https://govnokod.xyz/_26583
    #4: https://govnokod.ru/26689 https://govnokod.xyz/_26689
    #5: https://govnokod.ru/26784 https://govnokod.xyz/_26784
    #5: https://govnokod.ru/26839 https://govnokod.xyz/_26839
    #6: https://govnokod.ru/26986 https://govnokod.xyz/_26986
    #7: https://govnokod.ru/27007 https://govnokod.xyz/_27007
    #8: https://govnokod.ru/27023 https://govnokod.xyz/_27023
    #9: https://govnokod.ru/27098 https://govnokod.xyz/_27098
    #10: https://govnokod.ru/27125 https://govnokod.xyz/_27125
    #11: https://govnokod.ru/27129 https://govnokod.xyz/_27129
    #12: https://govnokod.ru/27184 https://govnokod.xyz/_27184
    #13: https://govnokod.ru/27286 https://govnokod.xyz/_27286
    #14: https://govnokod.ru/27298 https://govnokod.xyz/_27298
    #15: https://govnokod.ru/27322 https://govnokod.xyz/_27322
    #16: https://govnokod.ru/27328 https://govnokod.xyz/_27328
    #17: https://govnokod.ru/27346 https://govnokod.xyz/_27346
    #18: https://govnokod.ru/27374 https://govnokod.xyz/_27374
    #19: https://govnokod.ru/27468 https://govnokod.xyz/_27468
    #20: https://govnokod.ru/27469 https://govnokod.xyz/_27469
    #21: https://govnokod.ru/27479 https://govnokod.xyz/_27479
    #22: https://govnokod.ru/27485 https://govnokod.xyz/_27485
    #23: https://govnokod.ru/27493 https://govnokod.xyz/_27493
    #24: https://govnokod.ru/27501 https://govnokod.xyz/_27501

    nepeKamHblu_nemyx, 16 Июля 2021

    Комментарии (2382)
  9. JavaScript / Говнокод #27520

    +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
    abstract class Department {
        constructor(public name: string) {}
    
        printName(): void {
            print("Department name: " + this.name);
        }
    
        abstract printMeeting(): void; // must be implemented in derived classes
    }
    
    class AccountingDepartment extends Department {
        constructor() {
            super("Accounting and Auditing"); // constructors in derived classes must call super()
        }
    
        printMeeting(): void {
            print("The Accounting Department meets each Monday at 10am.");
        }
    
        generateReports(): void {
            print("Generating accounting reports...");
        }
    }
    
    function main() {
        let department: Department; // ok to create a reference to an abstract type
        department = new AccountingDepartment(); // ok to create and assign a non-abstract subclass
        department.printName();
        department.printMeeting();
        //department.generateReports(); // error: department is not of type AccountingDepartment, cannot access generateReports
        print("done.");
    }

    Алилуя - я вам абстракты принес :)

    ASD_77, 16 Июля 2021

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

    +1

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    /* В отдельном файле */
    function Skif_Email(auth,em) {
    	em = em.substring(3,em.length-3);
    	auth = auth.substring(4,auth.length-4);
    	document.write('<a href="mailto:',em,'" title="Защищён от спам-роботов">',auth,'</a>');
    }
    
    /* На странице */
    
    <script type="text/javascript">Skif_Email('[email protected]', '[email protected]');</script>

    Какая защита )))

    HEu3BECTHblu_nemyx, 16 Июля 2021

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