mirror of
https://github.com/theoleuthardt/learningC.git
synced 2026-06-13 09:37:53 +00:00
Initial commit
This commit is contained in:
commit
826d4c8c9d
81 changed files with 7268 additions and 0 deletions
46
uebung7/aufgabe2.c
Normal file
46
uebung7/aufgabe2.c
Normal file
|
|
@ -0,0 +1,46 @@
|
|||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include "modules/list.h"
|
||||
|
||||
int main() {
|
||||
// A2 Liste auslagern und als abgeschlossene Einheit flexibel einsetzbar machen
|
||||
|
||||
// Befüllung mit verschiedenen Daten
|
||||
int number1 = 255;
|
||||
int number2 = rand() % 500;
|
||||
int number3 = rand() % 500;
|
||||
int number4 = rand() % 500;
|
||||
int number5 = rand() % 500;
|
||||
|
||||
Add(&number1);
|
||||
Add(&number2);
|
||||
Add(&number3);
|
||||
Add(&number4);
|
||||
Add(&number5);
|
||||
|
||||
// Ausgabe der Liste
|
||||
printf("%s%d\n", "Item 0: ", *(int *) Get(0));
|
||||
printf("%s%d\n", "Item 1: ", *(int *) Get(1));
|
||||
printf("%s%d\n", "Item 2: ", *(int *) Get(2));
|
||||
printf("%s%d\n", "Item 3: ", *(int *) Get(3));
|
||||
printf("%s%d\n", "Item 4: ", *(int *) Get(4));
|
||||
|
||||
// Contains Überprüfung
|
||||
if(Contains((void *) 255) != -1)
|
||||
printf("%d", "Die Zahl 255 ist am Index: ", Contains((void *) 255));
|
||||
|
||||
// Size von list
|
||||
printf("Anzahl der Elemente in der Liste: ");
|
||||
printf("%d\n", Size( ));
|
||||
|
||||
// Remove Test
|
||||
Remove(0);
|
||||
Remove(4);
|
||||
printf("%s%d\n", "Item 0: ", *(int *) Get(0));
|
||||
printf("%s%d\n", "Item 1: ", *(int *) Get(1));
|
||||
printf("%s%d\n", "Item 2: ", *(int *) Get(2));
|
||||
printf("%s%d\n", "Item 3: ", *(int *) Get(3));
|
||||
printf("%s%d\n", "Item 4: ", *(int *) Get(4));
|
||||
return 0;
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue