Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Catalog · How the catalog works
Anything · Lazarus or Delphi
Random projectRandom project

Records-and-Binary-search

Lab 1. Fills an array of records, sorts it multiple times and performs a binary search

View on GitHub

Member rating

No ratings yet.

Sign in to rate this project.

README

Lab №1. Records and Search


Task:

Step 1: Generate an array of records per 1000 items. Each entry consists of three fields 1 - Numeric field - an integer random number from the range 0-200 2 - The string field is 'my_test_' + k, where k is a string representation of the record number in the order of its creation (1> = k> = 1000) 3 - Logical field = false

Step 2: Print the generated array

Step 3: Sort the resulting array in ascending order of field 2 (a string field)

Step 4: Output the resulting array

Step 5: Search the array for the entry with the value of field 2 equal to the string entered from the keyboard. Use the search algorithm given by the teacher. Each time the value of the field of the current record is compared with the entered value, the value of the logical field of the current record changes to true. The search results are displayed on the screen

Step 6: Output the received array and calculate how many records have the value of the field 3 = true

Step 7: Assign to all elements of the array the value of the field 3 = false

Step 8: Sort the resulting array by increasing the field 1 (Numerical field)

Step 9: Print the resulting array

Step 10: search the array for all records with a numeric field equal to the number entered from the keyboard. Use the search algorithm given by the teacher. Each time the numeric field of the current record is compared to the entered number, the value of the logical field of the current record changes to true. The search results can be displayed in the following form: Required entries with a number equal to 27:

Field 1 Field 2 Field 3 27 my_test_3 true 27 my_test_471 true 27 my_test_500 true 27 my_test_782 true

Step 11: Output the received array and calculate how many records have the value of the field 3 = true

The program executes each item of the task and outputs each item with output to a separate file (Folder OutFiles)

Language: Delphi

Algorithm scheme:

Code:

pascal