Arranging strings by alphabet

FlamingClaw 0 Tallied Votes 1K Views Share

This small program shows that how we can arrange
strings by alphabet in a vector.By FlamingClaw

{
This small program shows that how we can arrange
strings by alphabet in a vector 
}
Program Program01;
Uses Crt;

Const
  n=5;

Var
  szo:Array[1..n]Of String[4];
  i:Byte;
  j:Byte;
  t:String[4];

Begin {main}
   For i:=1 To n Do
     Begin
      Write(i,' Give me max 4 chars from the alphabet: ');
      ReadLn(t);
      szo[i]:=t;
     End;
   For i:=1 To n-1 Do
     Begin
       For j:=i+1 To n Do
         Begin
           If (szo[i]>szo[j]) Then
             Begin
               t:=szo[i];        {*}
               szo[i]:=szo[j];
               szo[j]:=t;       {*}
             End;
         End;
     End;
   WriteLn;
   {write the arranged result}
   WriteLn('Arranged!');
   For i:=1 To n Do WriteLn(szo[i]);
   ReadLn;
End.{end of main}

{
-= Note By FlamingClaw =-

All programs created by me are written and tested
in Dev-Pascal 1.9.2 and/or Turbo Pascal 7.0

-= Created By FlamingClaw =-
-=2009.03.29=-
}
sobari 0 Newbie Poster

thanks

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.