generate functionSat, 04 Feb 2023

Create a String array with locks (with duplicate locks) that came to the online store. Create two kinds of collections HashSet and TreeSet in which we could add our charm. Display a list of HashSet and TreeSet at most once out of one.

struct lock { int number; char name[30]; int year; }; void create(lock *arr) { for (int i = 0; i < 5; i++) { printf("Enter number: "); scanf("%d/n", &arr[i].number); printf("Enter name: "); scanf("%s/n", arr[i].name); printf("Enter year: "); scanf("%d/n", &arr[i].year); } } void display(lock *arr) { for (int i = 0; i < 5; i++) { printf("Lock number %d\n", arr[i].number); printf("Name %s\n", arr[i].name); printf("Year %d\n", arr[i].year); } } void main() { lock arr[5]; create(arr); display(arr); }

Questions about programming?Chat with your personal AI assistant