University of Science and Technology Houari Boumediene Faculty of Computer Science Algorithmics and Data Structures Ingenieur - Info
University of Science and Technology Houari Boumediene Faculty of Computer Science Algorithmics and Data Structures Ingenieur - Info
TD N° 3: Records
Exercise 1 :
Consider the following records:
Type
TPoint = Record
x,y: integer;
End;
TSpace = Record
Position: Tpoint;
Area, Altitude: integer;
End ;
TVille = Record
InfoG: TSpace;
Name: string[25];
PopSize: integer; //population size
End;
Algorithm Exo1;
Var
TPoint = record x,y : Integer ; End;
TSpace= record Position : Tpoint ; Area, Altitude :integer ; End ;
TCity = record
InfoG : TSpace;
Name :String[25] ;
PopSize :Integer ;
End;
T : Array[100] of TCity ;
N,i : integer ;
V1, V2 : String ;
P1, P2 : integer ;
Correct : boolean ;
Begin
Repeat
Write ( “ How many cities ? “ ) ; Read (n) ;
Until (n > 0 and n <=100) ;
Exercise 2 :
We are interested in statistics related to forest fires in Algeria. Let T be an array of N Forest
fires (N≤100). Each TFire forest fire is characterized by a geographical position PG (x, y), a
wilaya Wilaya, a burned Area (in hectares), a start date DateStart and an end date
DateEnd. These dates are made up of Hour, Day, Month, and Year.
TDate = Record
Hour, Day, Month, Year : integer;
End;
TFire = Record
PG : TPositionG;
Wilaya : String ;
Area : real ;
DateStart, DateEnd : TDate ;
End ;
Algorithm exo2 ;
//put the type declaration here.
Var
i, N, nbrFire : integer;
T : Array [100] of TFire ;
Begin
Write(“How many forest fire do me have ?”);
Repeat Read(N); Until (N>0) and (N<=100);
End.