I am new to Pascal and have a sample.txt file with the following integers:
1 2
2 1
1 3
3 1
1 4
How do I find the integer from the file with the minimum and maximum occurrences in Pascal language? In the above example, max occurrences would be the integer 1 (occurs 5 times) and minimum would be 4 (occurs once).
I understand I must open the file and read the values in and I've figured out this much so far. Is there a shorter way to perform this?
var
V1, V2, V3, V4, V5, V6, V7, V8, V9, V10: Integer;
begin
Assign(F, 'sample.txt');
Reset(F);
read(F, V1);
read(F, V2);
read(F, V3);
read(F, V4);
read(F, V5);
read(F, V6);
read(F, V7);
read(F, V8);
read(F, V9);
read(F, V10);
writeln('Max Occurrence')
writeln('Min Occurrence')
Close(F);
writeln;
Thanks in advance!