ENG  RUSTimus Online Judge
Online Judge
Problems
Authors
Online contests
About Online Judge
Frequently asked questions
Site news
Webboard
Links
Problem set
Submit solution
Judge status
Guide
Register
Update your info
Authors ranklist
Current contest
Scheduled contests
Past contests
Rules
back to board

Discussion of Problem 1545. Hieroglyphs

what is wrong?什么毛病呢?
Posted by zsyzhbc_china 19 Mar 2009 10:10
program t1545;
var
  s,h:array [1..1000] of string;
  p:array [1..1000] of longint;
  x,k:string;
  a,b,n,i,j,m,l:longint;
begin
  readln(n);a:=1;
  for i:=1 to n do
    readln(s[i]);
  readln(k);
  b:=length(k);
  for i:=1 to n do
  begin
    l:=0;
    x:=s[i];
    for j:=1 to length(s[i]) do
    begin
      if x[j]=k[1] then
      begin
        for m:=0 to b-1 do
        if x[j+m]=k[m+1] then inc(l);
        if l=b then begin h[a]:=x; inc(a); end;
      end;
    end;
  end;
  for i:=1 to a-1 do
  begin
    l:=0;
    x:=h[i];
    for j:=1 to length(x) do
    begin
      if x[j]<>k  then
      l:=l+ord(x[j]);
    end;
    p[i]:=l;
  end;
  for i:=1 to a-2 do
  for j:=i+1 to a-1 do
  begin
    if p[i]>p[j] then
    begin
      l:=p[i];
      p[i]:=p[j];
      p[j]:=l;
      k:=h[i];
      h[i]:=h[j];
      h[j]:=k;
    end;
  end;
  for i:=1 to a-1 do
  writeln(h[i]);
end.
Re: what is wrong?什么毛病呢?
Posted by Valentina 6 Mar 2010 16:51
If I'm not mistaking, the string in Pascal can't be longer than 255 symbols. But may be I am...
Re: what is wrong?什么毛病呢?
Posted by amirani 21 Jul 2011 20:16
oh men ! what are you doing ? is this the program we want to write???
try this

type
   myarray=array [1..1000] of string;
var
      i,n:integer;
      a:myarray;
      s,s1:string;
begin
   readln (n);
   for i:=1 to n do
      readln (a[i]);
   readln (s);
   for i:=1 to n do
   begin
      s1:=a[i];
      if s1[1]=s then
         writeln (a[i])
   end;
end.