forked from freudenreichan/info2Praktikum-DobleSpiel
comitting number.c
This commit is contained in:
1 parent
bde3ed1062
commit
2285230f8a
2 files changed
+15
-5
No files matched your search
+7
-1
@@ -38,7 +38,7 @@ unsigned int *createNumbers(unsigned int len) {
|
||||
if (numArray == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
// search for duplicate in code
|
||||
// deletes duplicates and fills in with random number
|
||||
fillarray(numArray, len);
|
||||
for (unsigned int i = 0; i < --len; i++) {
|
||||
for (unsigned int j = i; j < len; j++) {
|
||||
@@ -59,8 +59,14 @@ unsigned int *createNumbers(unsigned int len) {
|
||||
return numArray;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
// Returns only the only number in numbers which is present twice. Returns zero on errors.
|
||||
unsigned int getDuplicate(const unsigned int numbers[], unsigned int len) {
|
||||
if (numbers == NULL) {
|
||||
return 0;
|
||||
}
|
||||
unsigned int duplicate = 0;
|
||||
int compare(const void *a, const void *b);
|
||||
int (*compareNumbers)(const void *a, const void *b) = &compare;
|
||||
|
||||
Reference in new issue
Block a user