Arranging strings by alphabet

FlamingClaw FlamingClaw is offline Offline Mar 29th, 2009, 3:30 pm |
0
This small program shows that how we can arrange
strings by alphabet in a vector.By FlamingClaw
Quick reply to this message  
Pascal and Delphi Syntax
  1. {
  2. This small program shows that how we can arrange
  3. strings by alphabet in a vector
  4. }
  5. Program Program01;
  6. Uses Crt;
  7.  
  8. Const
  9. n=5;
  10.  
  11. Var
  12. szo:Array[1..n]Of String[4];
  13. i:Byte;
  14. j:Byte;
  15. t:String[4];
  16.  
  17. Begin {main}
  18. For i:=1 To n Do
  19. Begin
  20. Write(i,' Give me max 4 chars from the alphabet: ');
  21. ReadLn(t);
  22. szo[i]:=t;
  23. End;
  24. For i:=1 To n-1 Do
  25. Begin
  26. For j:=i+1 To n Do
  27. Begin
  28. If (szo[i]>szo[j]) Then
  29. Begin
  30. t:=szo[i]; {*}
  31. szo[i]:=szo[j];
  32. szo[j]:=t; {*}
  33. End;
  34. End;
  35. End;
  36. WriteLn;
  37. {write the arranged result}
  38. WriteLn('Arranged!');
  39. For i:=1 To n Do WriteLn(szo[i]);
  40. ReadLn;
  41. End.{end of main}
  42.  
  43. {
  44. -= Note By FlamingClaw =-
  45.  
  46. All programs created by me are written and tested
  47. in Dev-Pascal 1.9.2 and/or Turbo Pascal 7.0
  48.  
  49. -= Created By FlamingClaw =-
  50. -=2009.03.29=-
  51. }
0
sobari sobari is offline Offline | 29 Days Ago
thanks
 
 

Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC