Школоло / Говнокод #27528 Ссылка на оригинал

0

  1. 1
  2. 2
  3. 3
  4. 4
  5. 5
  6. 6
  7. 7
  8. 8
  9. 9
  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 Threadwalker, (Updated )

Комментарии (40, +40)

Школоло / Говнокод #27324 Ссылка на оригинал

0

  1. 1
  2. 2
  3. 3
  4. 4
  5. 5
  6. 6
  7. 7
  8. 8
  9. 9
  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
program square;

var sep, input: string;
  i, j, n, m : integer;
  

begin
  write('sep:');
  readln(sep);
  
  write('str:');
  readln(input);
  
  for i:=1 to length(input) do write(input[i], ' ');
  writeln();
  for i:=2 to length(input)-1 do begin
    write(input[i]);
    for j:=1 to length(input)*2-3 do write (sep);
    writeln(input[length(input) - i + 1]);
  end;
  for i:=0 to length(input)-1 do 
    write(input[length(input)-i], ' ');
end.

Написала на скучной лекции программку на телефоне, чтобы распечатывать

Х У Й
У   У
Й У Х


и прочие интересности UwU

Пользуйтесь на здоровье, лицензия GNU GPL V3!

KoWe4Ka_l7porpaMMep KoWe4Ka_l7porpaMMep, (Updated )

Комментарии (18, +18)

Школоло / Говнокод #27297 Ссылка на оригинал

0

  1. 1
  2. 2
  3. 3
  4. 4
  5. 5
  6. 6
  7. 7
  8. 8
  9. 9
  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
type
.....
TSyncParamsPasser = class
   PassedJSON:String;
   constructor Create(RJS:String);
   procedure ProcessExternalCmd;
  end;
.....
.....
procedure TForm1.TCPServerExecute(AContext: TIdContext);
begin
.....
   SyncParamsPasser:=TSyncParamsPasser.Create(CustomData);
   TIdSync.SynchronizeMethod(SyncParamsPasser.ProcessExternalCmd);
   FreeAndNil(SyncParamsPasser);
.....
end;
.....
constructor TSyncParamsPasser.Create(RJS:String);
begin
 PassedJSON:=RJS;
end;

procedure TSyncParamsPasser.ProcessExternalCmd;
var
 JSON:TJSONObject;
begin
 JSON:=TJSONObject.ParseJSONValue(PassedJSON) as TJSONObject;
.....

Событие OnExecute компонента TCPServer вызывается из рабочего потока, в котором обрабатывается входящее подключение.

Способ передачи параметров в процедуру, выполняющуюся внутри Synchronize, с помощью класса.
Говно или сойдёт?

SmseR SmseR, (Updated )

Комментарии (7, +7)

Школоло / Говнокод #27214 Ссылка на оригинал

0

  1. 1
  2. 2
  3. 3
  4. 4
  5. 5
procedure ProgramRestart(Sender: TObject);
begin
   Application.Terminate;
   ShellExecute(0,'open',Application.ExeName,'','',SW_NORMAL); // ))
end;

Неделю когда-то пытался понять почему этот код не работает: "Я же программу вырубил? - вырубил... Я же ее запускаю? - запускаю... А че она не запускается?)))..."

vovka3003 vovka3003, (Updated )

Комментарии (36, +36)

Школоло / Говнокод #27031 Ссылка на оригинал

0

  1. 1
  2. 2
  3. 3
  4. 4
  5. 5
// добавляем новые ссылки
  for i := 0 to ATags.Count - 1 do
  begin
    // так мне кажется лучше
    Application.ProcessMessages;

кому или чему лучше кроме тебя, автор ?

xoodoo xoodoo, (Updated )

Комментарии (163, +163)

Школоло / Говнокод #26788 Ссылка на оригинал

0

  1. 1
  2. 2
  3. 3
  4. 4
  5. 5
  6. 6
  7. 7
  8. 8
  9. 9
  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
  90. 90
  91. 91
  92. 92
  93. 93
  94. 94
  95. 95
  96. 96
  97. 97
  98. 98
  99. 99
  100. 100
procedure TWorker.handleAdminClient(socket: TTCPBlockSocket; json: ISuperObject);
var
  msg: ansistring;
  request: SOString;
  //s: ISuperObject;
  res: ISuperObject;
begin
  res := json['data'];
  msg := json['func'].AsString;

  if msg = 'deletemarket' then
     begin
       database.deleteMarket(res.GetS('id'));
       msg:='getmarkets';
     end;
  if msg = 'addmarket' then
     begin
      database.addMarket(res.GetS('mapid'),res.GetS('name'),res.GetS('type_id'));
      msg:='getmarkets';
     end;
  if msg = 'setmarketitems' then
     begin
        database.setMarktItems(res.GetS('id'),res.GetA('items'));
        TSocketSender.sendStr(socket, '{"type":"' + msg + '","data":{"id":' + res.GetS('id') + '}}');
        exit;
     end;
  if msg = 'updatemarket' then
     begin
        database.updateMarkt(res.GetS('id'),res.GetS('name'),res.GetS('enabled'));
        TSocketSender.sendStr(socket, '{"type":"' + msg + '","data":{"id":' + res.GetS('id') + '}}');
        exit;
     end;
  if msg = 'getmarktitems' then
     begin
       request := database.getMarktItems(res.GetS('id'));
       TSocketSender.sendStr(socket, '{ "type" : "' + msg + '" , "data" : ' + request + '}');
       exit;
     end;

  if msg = 'getmarkets' then
     begin
       request := database.getMarkets();
       TSocketSender.sendStr(socket, '{ "type" : "' + msg + '" , "data" : ' + request + '}');
       exit;
     end;

  if msg = 'getmarkettypes' then
     begin
       request := database.getMarketTypes();
       TSocketSender.sendStr(socket, '{ "type" : "' + msg + '" , "data" : ' + request + '}');
       exit;
     end;
  if msg = 'getitems' then
  begin
    request := database.getAdminItems();
    TSocketSender.sendStr(socket, '{ "type" : "' + msg + '" , "data" : ' + request + '}');
    exit;
  end;
  if msg = 'getitemstypes' then
  begin
    request := database.getAdminItemsTypes();
    TSocketSender.sendStr(socket, '{ "type" : "' + msg + '" , "data" : ' + request + '}');
    exit;
  end;
  if msg = 'getitem' then
  begin
    request := database.getItem(res['itemid'].AsInteger).getJSON.AsString;
    TSocketSender.sendStr(socket, '{ "type" : "' + msg + '" , "data" : ' + request + '}');
    exit;
  end;
  if msg = 'additem' then
  begin
    request := database.addItem(res);
    TSocketSender.sendStr(socket, '{ "type" : "' + msg + '" , "data" : ' + request + '}');
    exit;
  end;
  if msg = 'setitem' then
  begin
    database.setItem(res);
    exit;
  end;
  if msg = 'getavatar' then
  begin
    getAvatar(socket);
    exit;
  end;
  if msg = 'acceptavatar' then
  begin
    acceptAvatar(res);
    exit;
  end;
  if msg = 'declineavatar' then
  begin
    declineAvatar(res);
    exit;
  end;
  if msg = 'admindata' then
  begin
    sendAdminData(socket);
    exit;

Ужаснитесь.

Cynicrus Cynicrus, (Updated )

Комментарии (7, +7)

Школоло / Говнокод #26436 Ссылка на оригинал

0

  1. 1
  2. 2
  3. 3
  4. 4
  5. 5
  6. 6
  7. 7
  8. 8
  9. 9
  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
  90. 90
  91. 91
  92. 92
  93. 93
  94. 94
begin
                 G4.Caption:='X';
                 if G5.Caption='' then
                 begin
                   G5.Caption:='X';
                   if G6.Caption='' then
                   begin
                     G6.Caption:='X';
                     if G7.Caption='' then
                     begin
                       G7.Caption:='X';
                       if G8.Caption='' then G8.Caption:='X' else
                       if sg8=1 then
                          G8.Font.Style:=[fsBold,fsStrikeOut];
                     end else
                     if sg7=1 then
                        G7.Font.Style:=[fsBold,fsStrikeOut];
                   end else
                   if sg6=1 then
                      G6.Font.Style:=[fsBold,fsStrikeOut];
                 end else
                 if sg5=1 then
                    G5.Font.Style:=[fsBold,fsStrikeOut];
               end else
               if sg4=1 then
                  G4.Font.Style:=[fsBold,fsStrikeOut];
             end else
             if sg3=1 then
                G3.Font.Style:=[fsBold,fsStrikeOut];
           end else
           if sg2=1 then
              G2.Font.Style:=[fsBold,fsStrikeOut];
           if H2.Caption='' then H2.Caption:='X' else
           if sh2=1 then H2.Font.Style:=[fsBold,fsStrikeOut];
           if F2.Caption='' then
           begin
             F2.Caption:='X';
             if E3.Caption='' then
             begin
               E3.Caption:='X';
               if D4.Caption='' then
               begin
                 D4.Caption:='X';
                 if C5.Caption='' then
                 begin
                   C5.Caption:='X';
                   if B6.Caption='' then
                   begin
                     B6.Caption:='X';
                     if A7.Caption='' then A7.Caption:='X' else
                     if sa7=1 then
                     A7.Font.Style:=[fsBold,fsStrikeOut];
                   end else
                   if sb6=1 then
                   B6.Font.Style:=[fsBold,fsStrikeOut];
                 end else
                 if sc5=1 then
                 C5.Font.Style:=[fsBold,fsStrikeOut];
               end else
               if sd4=1 then
               D4.Font.Style:=[fsBold,fsStrikeOut];
             end else
             if se3=1 then
             E3.Font.Style:=[fsBold,fsStrikeOut];
           end else
           if sf2=1 then
           F2.Font.Style:=[fsBold,fsStrikeOut];
         end;
      6: begin //Король
    {E1}   if ((se1=1) and not ((E1.Caption<>'Ферзь') or (E1.Caption<>'Ладья') or (E1.Caption<>'Король')) or
    {D1}   ((sd1=1) and not ((E1.Caption='') and ((D1.Caption='Ферзь') or (D1.Caption='Ладья')))) or
    {C1}   ((sc1=1) and not (((E1.Caption='') and (D1.Caption='')) and ((C1.Caption='Ферзь') or (C1.Caption='Ладья')))) or
    {B1}   ((sb1=1) and not (((E1.Caption='') and (D1.Caption='') and (C1.Caption='')) and ((B1.Caption='Ферзь') or (B1.Caption='Ладья')))) or
    {A1}   ((sa1=1) and not (((E1.Caption='') and (D1.Caption='') and (C1.Caption='') and (B1.Caption='')) and ((A1.Caption='Ферзь') or (A1.Caption='Ладья')))) or
    {E2}   ((se2=1) and not ((E2.Caption='Слон') or (E2.Caption='Ферзь') or (E2.Caption='Пешка') or (E2.Caption='Король'))) or
    //ПРОДОВЖИТИ
    {D3}   ((sd3=1) and not ((E2.Caption='') and ((D3.Caption='Ферзь') or (D3.Caption='Слон')))) or
    {C4}   ((sc4=1) and not (((E2.Caption='') and (D3.Caption='')) and ((C4.Caption='Ферзь') or (C4.Caption='Слон')))) or
    {B5}   ((sb5=1) and not (((E2.Caption='') and (D3.Caption='') and (C4.Caption='')) and ((B5.Caption='Ферзь') or (B5.Caption='Слон')))) or
    {A6}   ((sa6=1) and not (((E2.Caption='') and (D3.Caption='') and (C4.Caption='') and (B5.Caption='')) and ((A6.Caption='Ферзь') or (A6.Caption='Ладья')))) or
    {F2}   ((sf2=1) and not (E2.Caption='Ладья') or (E2.Caption='Ферзь')) or
    {F3}   ((sf3=1) and not ((F2.Caption='') and ((F3.Caption='Ферзь') or (F3.Caption='Ладья')))) or
    {F4}   ((sf4=1) and not (((F2.Caption='') and (F3.Caption='')) and ((F4.Caption='Ферзь') or (F4.Caption='Ладья')))) or
    {F5}   ((sf5=1) and not (((F2.Caption='') and (F3.Caption='') and (F4.Caption='')) and ((F5.Caption='Ферзь') or (F5.Caption='Ладья')))) or
    {F6}   ((sf6=1) and not (((F2.Caption='') and (F3.Caption='') and (F4.Caption='') and (F5.Caption='')) and ((F6.Caption='Ферзь') or (F6.Caption='Ладья')))) or
    {F7}   ((sf7=1) and not (((F2.Caption='') and (F3.Caption='') and (F4.Caption='') and (F5.Caption='') and (F6.Caption='')) and ((F7.Caption='Ферзь') or (F7.Caption='Ладья')))) or
    {F8}   ((sf8=1) and not (((F2.Caption='') and (F3.Caption='') and (F4.Caption='') and (F5.Caption='') and (F6.Caption='') and (F7.Caption='')) and ((F8.Caption='Ферзь') or (F8.Caption='Ладья')))) or
    {G2}   ((sg2=1) and not (G2.Caption='Ферзь') or (G2.Caption='Слон')) or
    {H3}   ((sh3=1) and not ((G2.Caption='') and ((H3.Caption='Ферзь') or (H3.Caption='Слон')))) or
    {H1}   ((sh1=1) and not (H1.Caption'Ферзь') or (H1.Caption='Слон')) or
   {Кони}  ((sh2=1) and not (H2.Caption='Конь')) or ((sg3=1) and not (G3.Caption='Конь')) or  ((se3=1) and not (E3.Caption='Конь')) or  ((sd2=1) and not(D2.Caption='Конь'))
           ) then if (F1.Caption='') then F1.Caption:='X' else
           if sf1=1 then F1.Font.Style:=[fsBold,fsStrikeOut];
         end;

Как-то на первом или втором курсе недоунивера возникло желание сделать шахматы в ООП на Паскале. Решил закодить 64 кнопки (8*8 поле). Сделал переменные для идентификации хода черных/белых, для 2 режимов, в первом из которых кликаешь на свою фигуру (надпись на кнопке) и тебе показывают доступные ходы ею (Х куда можно поставить фигуру, подчеркнутое название вражеской фигуры при возможность её забрать). Ты кликаешь, поле очищается от подсказок, фигура перемещается, проверка на шах/мат (ад), ход передается другому цвету фигур (Жирное начертание для определения) и режим взаимодействия с игровым полем опять переходит в выбор фигуры. Теоретически закодировав каждую кнопку на все возможные события шахматы были бы закончены полностью. Вот только спустя окончания кодировки первой кнопки я заYAYлся и забросил ибо говнокод вышел в 1000 строк на одну YAYдь кнопку. Разумеется, показать могу лишь часть

Zick Zick, (Updated )

Комментарии (38, +38)