Advertisement
Guest User

Untitled

a guest
Nov 22nd, 2017
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.36 KB | None | 0 0
  1. program dop;
  2.  
  3. const
  4. lmax = 20;
  5.  
  6. type
  7. massstr = array [1..lmax] of string;
  8. nomer = array [1..lmax] of integer;
  9.  
  10. var
  11. mass1, mass2, checkmass: massstr;
  12. nom: nomer;
  13. k1, k2, i, num, kol: integer;
  14. check: string;
  15.  
  16. procedure task1(var mass1: massstr; k1: integer);
  17. var
  18. flag: boolean;
  19. i, n, j, l, x, c, max, nom1, k, nom2: integer;
  20. chr: string;
  21. begin
  22. chr := 'qwertyuiopasdfghjklzxcvbnmQWERTYUIOPASDFGHJKLZXCVBNM';
  23. for i := 1 to k1 do
  24. begin
  25. n := length(mass1[i]);
  26. nom1 := 0;
  27. max := 0;
  28. flag := false;
  29. l := 0;
  30. kol := 0;
  31. k2 := 0;
  32. begin
  33. if
  34.  
  35. while (j<n) and (pos(mass1[i][j], chr) > 0) do
  36. begin
  37. inc(nom2);
  38. if nom1 = 0 then
  39. nom1 := j;
  40. inc(j);
  41. end;
  42. begin
  43. if nom2-nom1>= max then
  44. mass2[i]:=copy(mass1[i],nom1,nom2-nom1+1);
  45. writeln(mass2[j],' ', j, ' ');
  46. nom1:=0;
  47. nom2:=0;
  48. end;
  49. end;
  50. {if k2 = 0 then
  51. writeln('Нет изменений в строке ', i)
  52. else
  53. flag := true;
  54. for k := 1 to k2 do
  55. if mass2[k].Length >= max then
  56. max := mass2[k].Length;
  57. for j := 1 to n do
  58. begin
  59. if pos(mass1[i][j], chr) > 0 then
  60. nom1 := j
  61. else
  62. begin
  63. inc(k2);
  64. if k2 = max then
  65. Insert('1', mass1[i], j - 1);}
  66. end;
  67. nom1:=0;
  68. nom2:=0;
  69. for i:=1 to k1 do
  70. for j := 1 to Length(mass1[i]) do
  71. begin
  72. if (pos(mass1[i][j], chr) =0) or (j=Length(mass1[i])) then
  73. begin
  74. if j-nom2<>j-1 then
  75. nom2:=j;
  76. writeln(nom1,' ',nom2,'Длина слова ',nom2-nom1,'Длина максимального слова ',mass2[i].Length);
  77. if nom2-nom1=mass2[i].Length then
  78. Insert('1',mass1[i],nom2);
  79. nom1:=0;
  80. nom2:=0;
  81. end
  82. else
  83. begin
  84. if nom1 = 0 then
  85. nom1 := j;
  86. end
  87.  
  88. end;
  89. end;
  90.  
  91.  
  92.  
  93.  
  94. begin
  95. writeln('Задание №1');
  96. repeat
  97. writeln('Введите количество строк: ');
  98. readln(check);
  99. until (integer.TryParse(check, k1)) and (k1 <= lmax) and (k1 > 0);
  100. writeln('Введите ', k1, ' строк: ');
  101. for i := 1 to k1 do
  102. readln(mass1[i]);
  103. task1(mass1, k1);
  104. for i := 1 to k1 do
  105. writeln(mass1[i]);
  106. end.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement