Write a program to determine friendship relationships.
First, we need to define what a person is. We assume there are n people, each with an integer id between 1 and n, and a name of at most 32 characters. According to the usual definition, friendship is mutual.
Suppose you have a binary file friends that contains all friendship information.
The file friends contains the following data in order:
The number of people n, occupying 4 bytes.
The contents of n structs of type person.
The number of friendship pairs f, occupying 4 bytes.
The contents of f structs of type friends.
Next, you need to read a series of commands from the keyboard.
Each command contains two names.
If the two names are friends—that is, if there exists a struct friends entry that matches the two names—output "yes"; otherwise, output "no".
The program must process all input until EOF.
The two names.
Ex. John Mary
Tom Mary
Jack Tom
Whether if they are friends.
Ex. yes
no
no