Dennnhhhickk

Untitled

Oct 14th, 2016
58
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.20 KB | None | 0 0
  1. Program First;
  2. const
  3. MAXIN = 100000;
  4. var
  5. s, s1:string;
  6. i, in1, k: integer;
  7. f, t:text;
  8. a: array [0..MAXIN] of integer;
  9. begin
  10. assign(f,'input.txt');
  11. reset(f);
  12. assign(t,'output.txt');
  13. rewrite(t);
  14.  
  15. readln(f, s);
  16. readln(f, s1);
  17. k := 0;
  18. i := 1;
  19. in1 := 1;
  20.  
  21. while(i <= length(s)) do
  22. begin
  23. if not(upcase(s[i]) in ['A'..'Z']) then
  24. begin
  25. a[in1] := k;
  26. delete(s, in1, k);
  27. if (k <> 0) then
  28. begin
  29. i := in1 + 1;
  30. k := 0;
  31. insert('?', s, in1);
  32. end;
  33. end
  34. else
  35. if (k = 0) and (upcase(s[i]) in ['A'..'Z']) then
  36. begin
  37. in1 := i;
  38. k := 1;
  39. end
  40. else
  41. if (upcase(s[i]) in ['A'..'Z']) then
  42. inc(k);
  43. i := i + 1;
  44. end;
  45.  
  46. if (k <> 0) then
  47. begin
  48. a[in1] := length(copy(s, in1, k));
  49. delete(s, in1, k);
  50. k := 0;
  51. insert('?', s, in1);
  52. end;
  53.  
  54. k := 0;
  55. for i := 1 to length(s) do
  56. if (s[i] <> s1[i]) then
  57. begin
  58. writeln(t, k);
  59. close(f);
  60. close(t);
  61. exit;
  62. end
  63. else
  64. if (s[i] <> '?') then
  65. inc(k)
  66. else
  67. inc(k, a[i]);
  68. writeln(t, k);
  69. close(f);
  70. close(t);
  71. end.
Advertisement
Add Comment
Please, Sign In to add comment