Advertisement
sbitnev

kirill

Nov 30th, 2015
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pascal 1.50 KB | None | 0 0
  1. Program example1;
  2.  
  3. type
  4. m = array[1..10] of string;
  5.  
  6. Procedure first(n1:integer; T1:m;var n2:integer; var T2:m);
  7. var
  8. i,j,j1:integer;
  9. //T2 :array[1..10] of string;
  10. begin
  11.  
  12. n2:=0; {число подстрок}
  13. for i:=1 to n1 do
  14.  begin
  15.   j:=1; {номер символа}
  16.   j1:=1; {начало подстроки}
  17.   while j<=length(T1[i]) do
  18.     if (T1[i][j] >='[') and (T1[i][j]<=']' ) then
  19.      begin
  20.       if j<>1 then
  21.         begin
  22.         n2:=n2+1;
  23.         T2[n2]:=copy(T1[i],j1,j-j1);
  24.         end;
  25. while (j<=length(T1[i]))and (T1[i][j] >='[')and (T1[i][j]<=']' ) do
  26.        j:=j+1;
  27.        j1:=j;
  28.       end
  29.     else
  30.       j:=j+1;
  31.   if j<>j1 then
  32.     begin
  33.     n2:=n2+1;
  34.     T2[n2]:=copy(T1[i],j1,j-j1);
  35.     end;
  36.  end;
  37. if n2=0 then
  38.   writeln('Нет подстрок')
  39. else
  40.   begin
  41.     writeln('Подстроки');
  42.     for i:=1 to n2 do writeln(T2[i]);
  43.   end;
  44. end;
  45.  
  46. Procedure second(n2:integer;T2:m);
  47. var
  48. i,hg:integer;
  49. min,stroka:string;
  50. begin
  51. min:=',,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,';
  52.  for i:=1 to n2 do
  53.   begin
  54.   if length(T2[i]) < length(min) then
  55.     begin
  56.          min:=T2[i];
  57.          hg:=i;
  58.     end;
  59.   end;
  60.   writeln('the shortest line ',min);
  61.   writeln('the number of shortest line ',hg);
  62. end;
  63.  
  64. {Main programm}
  65.  
  66. var
  67.  
  68. n2,n1,i:integer;
  69. T1,T2:m;
  70. begin
  71.   writeln('Введите число строк n1');
  72. readln(n1);
  73. writeln('Введите строки');
  74. for i:=1 to n1 do
  75.   readln(T1[i]);
  76.   first(n1,T1,n2,T2);
  77.   second(n2,T2);
  78. end.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement