home bbs files messages ]

Forums before death by AOL, social media and spammers... "We can't have nice things"

   comp.lang.pascal.borland      Borland Pascal was actually pretty neat      2,978 messages   

[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]

   Message 1,490 of 2,978   
   Jochen to All   
   Re: To Sort into array help   
   31 Mar 05 00:45:20   
   
   31b4d09f   
   From: jotel99@hotmail.com   
      
   hi,   
      
   MALMSTROM typed:   
   > Hi everyone, I expect these procedures to sort the integers given and   
   > write the sorted integers into an array with its original order.   
   >   
   > However,it simply follows the original array's information and let   
   > '0's after first 2 insert of those integers.   
   >   
   > How to make the following procedure create marksheet like:   
   > ______________________   
   > unsorted data:55 44 33   
   > sorted data:33 44 55   
   > here is the marksheet:   
   >            33   
   >            44   
   >            55   
   > _______________________   
   > but not like this:   
   > ____________________   
   >            55   
   >            44   
   >             0   
   >  ______________________   
   >   
   > type   
   >   arrst=array[1..5,1..5] of string;   
   >   arrin=array[1..5] of integer;   
   > procedure bbssort(arr:arrin;max:integer);   
      
   if this is your sorting routine... ok... but ...   
   you are working on a local copy of the "arr".   
   your  procedure might sort the data - but won't give it back to the   
   calling instance.   
      
   learn more about parameters.   
      
   => procedure bbssort( {!}VAR{!} arr:arrin;max:integer);   
      
   rest untested.   
      
   >   var i,y,pass:integer;sorted:boolean;   
   >   begin   
   >     pass:=1;   
   >     repeat   
   >       sorted:=true;   
   >       FOR i:= 1 TO max-1 DO   
   >       begin   
   >         if arr[i] > arr[i+1] then   
   >         begin   
   >           sorted:=false;   
   >           y:=arr[i];   
   >           arr[i]:=arr[i+1];   
   >           arr[i+1]:=y;   
   >         end;   
   >       end;   
   >       pass:=pass+1;   
   >     until sorted;   
   >     writeln(arr[3]);   
   >   end;   
   > procedure sortedsheet(max:integer;arra:arrin;arrb: arrst);   
   > var i:integer;   
   >   begin   
   >     i:=1;   
   >     repeat   
   >       str(arra[i],arrb[i,3]);   
   >       i:=i+1;   
   >     until (i=5);   
   >     writeln(arrb[3,3]);   
   >   writeln('Here is the marksheet:');   
   >   writeln('Name      Sex    English    Chinese   Computer');   
      
   [...]   
      
   very confusing code - nested loops are not bad and valid ;)   
      
   --   
   http://radio789.net.ms - Radio 789 - We play it ALL   
   Radiostream: http://stream789.net.ms   
      
   --- SoupGate-Win32 v1.05   
    * Origin: you cannot sedate... all the things you hate (1:229/2)   

[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]


(c) 1994,  bbs@darkrealms.ca