Homework 6 ex 5
You cannot submit for this problem because the homework's deadline is due.
Description
A mathematical set is a collection of distinct objects, such as {1, 3, 9}, {\(r\), \(g\), \(b\)}, and {5, 11, 11} = {5, 11}. Based on the universal set header file below write in a corresponding ex5.c file the necessary functions to handle a set (creation, deletion as well as adding and removing elements). Assume a set can contain elements of type either char
, int
or double
.
Hint: to resize a memory block use the function realloc
.
Format
Files
You should submit a tar file containing a c source file ex5.c
. It should be like:
#include "universal_set.h"
// Add some code
void newSet(uset **set, int type) {
// Add some code
}
void deletSet(uset **set) {
// Add some code
}
void addElem(void *elem, uset *set) {
// Add some code
}
void remElem(void *elem, uset *set) {
// Add some code
}
Input
elements type and operation number \(n\) on the first line.
an operation on the next \(n\) lines
Output
\(n\) lines of elements in the set (sorted by us) after each operation
Sample 1
Input:
char 4
add 1
add 2
add 3
add 4
Output:
1
1 2
1 2 3
1 2 3 4
Hint
Limitation
1s, 128MiB for each test case.
Homework 6
- Status
- Finished
- Problems
- 6
- Open Since
- 2022-11-05 00:00
- DDL
- 2022-11-18 23:59
- Extension
- 24.0 hour(s)