Help needed understanding Parallel Arrays 
Author Message
 Help needed understanding Parallel Arrays

Hi Everyone

Can anyone show me an example of source code or tell me how to use (that is:
input data, output data, display contents of, sort) in a set of parallel
arrays,

A parallel array is where:

cell1 in array1 is associated with cell1 of array2,
cell2 in array2 is associated with cell2 of array2,
etc

eg: One array stores the names of athletes (as strings) and the other stores
their scores in competition.

Thanks

--
Neerav :-]

Webmaster of the Adextinguisher homepage.
Adextinguisher is freeware a banner ad blocking program
located at http://www.*-*-*.com/ ~neeravb/adext



Wed, 18 Jun 1902 08:00:00 GMT  
 Help needed understanding Parallel Arrays


Quote:
> Hi Everyone

> Can anyone show me an example of source code or tell me how to use
> (that is:
> input data, output data, display contents of, sort) in a set of
> parallel arrays,

> A parallel array is where:

> cell1 in array1 is associated with cell1 of array2,
> cell2 in array2 is associated with cell2 of array2,
> etc

> eg: One array stores the names of athletes (as strings) and the other
> stores their scores in competition.

type
  plork = record
            name: string[20];
            score: integer;
          end;

var
  par_arr: array [1..whatever] of plork;

HTH,

Robert
--
Robert AH Prins

Sent via Deja.com http://www.deja.com/
Before you buy.



Wed, 18 Jun 1902 08:00:00 GMT  
 Help needed understanding Parallel Arrays


Quote:
>Hi Everyone

>Can anyone show me an example of source code or tell me how to use (that is:
>input data, output data, display contents of, sort) in a set of parallel
>arrays,

>A parallel array is where:

>cell1 in array1 is associated with cell1 of array2,
>cell2 in array2 is associated with cell2 of array2,
>etc

>eg: One array stores the names of athletes (as strings) and the other stores
>their scores in competition.

>Thanks

If you really want to use parallel arrays, just assign a variable to
keep up with the array index and use that index for each array.
However, as you have already been told, a better way is to use an
array of records, which is not really a parallel array. You can use
any datatype you wish within a record. You would probably want to
declare another user TYPE as s25 = String[25] (or whatever length you
choose) for use as the athelete's name string to save memory.

Clif



Wed, 18 Jun 1902 08:00:00 GMT  
 Help needed understanding Parallel Arrays
Hi Neerav

For the puposes of this assignment try this or anything similar (this just
makes it easy to see what each type may be doing);

TYPE
  range = 1 .. maxdivers;  { maxdivers is a CONST of 10 }
  NameArrayType : ARRAY[range] OF STRING [32];
  RawScoreArrayType : ARRAY[1 .. maxjudge] OF REAL;  { maxjudge is CONST of
6}
  CorrectedScoreArrayType : ARRAY[range] OF REAL;
  TotalScoreArrayType : ARRAY[range] OF REAL;

VAR
  name : nameArrayType;
  total : totalscoreArrayType;

Use the rawscorearraytype to record the raw scores awarded by judges
then when the corrected scores are calculated send them to the
CorrectedScore array.
And accumulate them in totalscorearraytype.
You'll need these two when it comes to sorting the scores.

To load the arrays:

Var
  i, j : INTEGER

FOR i := 1 TO numOfDivers DO
  Begin {for}
    WRITE('Enter name of Diver ',i:1' : ');
    READLN(name[i]);
  End; {for}
FOR j := 1 TO numOfDivers DO
  WRITELN('Diver number ',j:1,' is ',name[j]);

To read in two sets just add the other to the loop
  FOR i := 1 TO numOfDivers DO
    begin {for}
      WRITE('Enter name : ');
      READLN(name[i]);
      WRITE('Enter Score :');
      READLN(total[i]);
    end; {for}

If these values are being passed from another procedure make them parameters
in your procedure heading.


Quote:
> Hi Everyone

> Can anyone show me an example of source code or tell me how to use (that
is:
> input data, output data, display contents of, sort) in a set of parallel
> arrays,

> A parallel array is where:

> cell1 in array1 is associated with cell1 of array2,
> cell2 in array2 is associated with cell2 of array2,
> etc

> eg: One array stores the names of athletes (as strings) and the other
stores
> their scores in competition.

> Thanks

> --
> Neerav :-]

> Webmaster of the Adextinguisher homepage.
> Adextinguisher is freeware a banner ad blocking program
> located at http://www.crosswinds.net/~neeravb/adext



Wed, 18 Jun 1902 08:00:00 GMT  
 Help needed understanding Parallel Arrays
Hi

Brads suggestion was best as my programming assignment requires the usemof
parallel arrays.

Thanks

Neerav


Quote:
> Hi Neerav

> For the puposes of this assignment try this or anything similar (this just
> makes it easy to see what each type may be doing);

> TYPE
>   range = 1 .. maxdivers;  { maxdivers is a CONST of 10 }
>   NameArrayType : ARRAY[range] OF STRING [32];
>   RawScoreArrayType : ARRAY[1 .. maxjudge] OF REAL;  { maxjudge is CONST
of
> 6}
>   CorrectedScoreArrayType : ARRAY[range] OF REAL;
>   TotalScoreArrayType : ARRAY[range] OF REAL;

> VAR
>   name : nameArrayType;
>   total : totalscoreArrayType;

> Use the rawscorearraytype to record the raw scores awarded by judges
> then when the corrected scores are calculated send them to the
> CorrectedScore array.
> And accumulate them in totalscorearraytype.
> You'll need these two when it comes to sorting the scores.

> To load the arrays:

> Var
>   i, j : INTEGER

> FOR i := 1 TO numOfDivers DO
>   Begin {for}
>     WRITE('Enter name of Diver ',i:1' : ');
>     READLN(name[i]);
>   End; {for}
> FOR j := 1 TO numOfDivers DO
>   WRITELN('Diver number ',j:1,' is ',name[j]);

> To read in two sets just add the other to the loop
>   FOR i := 1 TO numOfDivers DO
>     begin {for}
>       WRITE('Enter name : ');
>       READLN(name[i]);
>       WRITE('Enter Score :');
>       READLN(total[i]);
>     end; {for}

> If these values are being passed from another procedure make them
parameters
> in your procedure heading.



> > Hi Everyone

> > Can anyone show me an example of source code or tell me how to use (that
> is:
> > input data, output data, display contents of, sort) in a set of parallel
> > arrays,

> > A parallel array is where:

> > cell1 in array1 is associated with cell1 of array2,
> > cell2 in array2 is associated with cell2 of array2,
> > etc

> > eg: One array stores the names of athletes (as strings) and the other
> stores
> > their scores in competition.

> > Thanks

> > --
> > Neerav :-]

> > Webmaster of the Adextinguisher homepage.
> > Adextinguisher is freeware a banner ad blocking program
> > located at http://www.crosswinds.net/~neeravb/adext



Wed, 18 Jun 1902 08:00:00 GMT  
 
 [ 5 post ] 

 Relevant Pages 

1. Need help with getting data from parallel port

2. I need help about Parallel port

3. Parallel port I/O code needed.

4. Parallel port I/O programming code needed.

5. Need Help in Array!

6. Urgent help with arrays needed please

7. Need help with 3D arrays.

8. Need help in function and array!

9. ARRAYS!! need help from all the genius

10. Sorting arrays help needed

11. Need Help with sorting through numbers in an array

12. I need to make a large array for my Computing A-Level project - can you help

 

 
Powered by phpBB® Forum Software