init
This commit is contained in:
@@ -0,0 +1,9 @@
|
|||||||
|
*.a
|
||||||
|
*.lib
|
||||||
|
*.o
|
||||||
|
*.obj
|
||||||
|
*.out
|
||||||
|
|
||||||
|
.idea/
|
||||||
|
*~
|
||||||
|
*.DotSettings.user
|
||||||
Binary file not shown.
|
After Width: | Height: | Size: 1.7 MiB |
@@ -0,0 +1,15 @@
|
|||||||
|
CC=gcc
|
||||||
|
CFLAGS=-Wall -Wextra -Werror -fsanitize=address -g -pedantic
|
||||||
|
|
||||||
|
SRCS=dlist.c main.c
|
||||||
|
OBJS=$(SRCS:.c=.o)
|
||||||
|
|
||||||
|
TARGET=dlist
|
||||||
|
|
||||||
|
all: $(TARGET)
|
||||||
|
|
||||||
|
$(TARGET): $(OBJS)
|
||||||
|
$(CC) $(CFLAGS) -o $@ $^
|
||||||
|
|
||||||
|
clean:
|
||||||
|
$(RM) -r $(TARGET) $(OBJS)
|
||||||
@@ -0,0 +1,63 @@
|
|||||||
|
#include "dlist.h"
|
||||||
|
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
|
||||||
|
struct dlist *dlist_init(void)
|
||||||
|
{
|
||||||
|
// TODO
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
void dlist_clear(struct dlist *list)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
size_t dlist_length(struct dlist *l)
|
||||||
|
{
|
||||||
|
// TODO
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
void dlist_push_front(struct dlist *l, int data)
|
||||||
|
{
|
||||||
|
// TODO
|
||||||
|
}
|
||||||
|
|
||||||
|
void dlist_push_back(struct dlist *l, int data)
|
||||||
|
{
|
||||||
|
// TODO
|
||||||
|
}
|
||||||
|
|
||||||
|
void dlist_remove(struct dlist *list, int data)
|
||||||
|
{
|
||||||
|
// TODO
|
||||||
|
}
|
||||||
|
|
||||||
|
struct dlist *dlist_from_str(char *str)
|
||||||
|
{
|
||||||
|
// TODO
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
struct node *dlist_find(struct dlist *list, int data)
|
||||||
|
{
|
||||||
|
// TODO
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
void dlist_print(struct dlist *l)
|
||||||
|
{
|
||||||
|
// TODO
|
||||||
|
}
|
||||||
|
|
||||||
|
void dlist_concat(struct dlist *l1, struct dlist *l2)
|
||||||
|
{
|
||||||
|
// TODO
|
||||||
|
}
|
||||||
|
|
||||||
|
void dlist_insert(struct dlist *l, int data, int i)
|
||||||
|
{
|
||||||
|
// TODO
|
||||||
|
}
|
||||||
@@ -0,0 +1,8 @@
|
|||||||
|
// This file will not be tested, you can modify it.
|
||||||
|
|
||||||
|
#include "dlist.h"
|
||||||
|
|
||||||
|
int main(void)
|
||||||
|
{
|
||||||
|
// TODO
|
||||||
|
}
|
||||||
@@ -0,0 +1,16 @@
|
|||||||
|
CC = gcc
|
||||||
|
CFLAGS = -Wall -Wextra -Werror
|
||||||
|
|
||||||
|
all: fork.o main.o
|
||||||
|
|
||||||
|
|
||||||
|
is_prime: fork.o main.o
|
||||||
|
$(CC) $^ -o $@
|
||||||
|
|
||||||
|
salute: fork.o main.o
|
||||||
|
$(CC) $^ -o $@
|
||||||
|
|
||||||
|
clean:
|
||||||
|
$(RM) fork.o main.o is_prime salute
|
||||||
|
|
||||||
|
.PHONY: all clean run
|
||||||
@@ -0,0 +1,19 @@
|
|||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <string.h>
|
||||||
|
#include <sys/wait.h>
|
||||||
|
#include <unistd.h>
|
||||||
|
|
||||||
|
#include "fork.h"
|
||||||
|
|
||||||
|
int is_prime(size_t n)
|
||||||
|
{
|
||||||
|
// TODO
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
int salute(int num_guests, char *guests[])
|
||||||
|
{
|
||||||
|
// TODO
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
@@ -0,0 +1,9 @@
|
|||||||
|
#ifndef FORK_H
|
||||||
|
#define FORK_H
|
||||||
|
|
||||||
|
#include <stddef.h>
|
||||||
|
|
||||||
|
int is_prime(size_t n);
|
||||||
|
int salute(int num_guests, char *guests[]);
|
||||||
|
|
||||||
|
#endif /* FORK_H */
|
||||||
@@ -0,0 +1,28 @@
|
|||||||
|
// This file will not be tested, you can modify it.
|
||||||
|
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
|
#include "fork.h"
|
||||||
|
|
||||||
|
int main(int argc, char *argv[])
|
||||||
|
{
|
||||||
|
if (!strcmp(argv[0], "./is_prime"))
|
||||||
|
{
|
||||||
|
for (int i = 1; i < argc; i++)
|
||||||
|
{
|
||||||
|
is_prime(atoi(argv[i]));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (!strcmp(argv[0], "./salute"))
|
||||||
|
{
|
||||||
|
return salute(argc, argv);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
printf("No such thing as %s\n", argv[0]);
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
@@ -0,0 +1,14 @@
|
|||||||
|
CC=gcc
|
||||||
|
CFLAGS=-Wall -Wextra -Werror -fsanitize=address -g
|
||||||
|
|
||||||
|
SRCS=main.c dlist.c dlist_merge_sort.c
|
||||||
|
OBJS=$(SRCS:.c=.o)
|
||||||
|
TARGET=dlist_merge_sort
|
||||||
|
|
||||||
|
all: $(TARGET)
|
||||||
|
|
||||||
|
$(TARGET): $(OBJS)
|
||||||
|
$(CC) $(CFLAGS) -o $@ $(OBJS)
|
||||||
|
|
||||||
|
clean:
|
||||||
|
$(RM) $(OBJS) $(TARGET)
|
||||||
@@ -0,0 +1,6 @@
|
|||||||
|
#include "dlist_merge_sort.h"
|
||||||
|
|
||||||
|
void dlist_merge_sort(struct dlist *l)
|
||||||
|
{
|
||||||
|
// TODO
|
||||||
|
}
|
||||||
@@ -0,0 +1,25 @@
|
|||||||
|
#ifndef DLIST_MERGE_SORT
|
||||||
|
#define DLIST_MERGE_SORT
|
||||||
|
|
||||||
|
#include <stddef.h>
|
||||||
|
|
||||||
|
struct node
|
||||||
|
{
|
||||||
|
int data;
|
||||||
|
struct node *next;
|
||||||
|
struct node *prev;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct dlist
|
||||||
|
{
|
||||||
|
size_t size;
|
||||||
|
struct node *head;
|
||||||
|
struct node *tail;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct dlist *dlist_init(void);
|
||||||
|
void dlist_clear(struct dlist *list);
|
||||||
|
void dlist_push_back(struct dlist *l, int data);
|
||||||
|
void dlist_merge_sort(struct dlist *l);
|
||||||
|
|
||||||
|
#endif /* ! DLIST_MERGE_SORT */
|
||||||
@@ -0,0 +1,29 @@
|
|||||||
|
// This file will not be tested, you can modify it.
|
||||||
|
|
||||||
|
#include <stdio.h>
|
||||||
|
|
||||||
|
#include "dlist_merge_sort.h"
|
||||||
|
|
||||||
|
static void dlist_print(struct dlist *dl)
|
||||||
|
{}
|
||||||
|
|
||||||
|
int main(void)
|
||||||
|
{
|
||||||
|
struct dlist *l = dlist_init();
|
||||||
|
dlist_push_back(l, 4);
|
||||||
|
dlist_push_back(l, 2);
|
||||||
|
dlist_push_back(l, 5);
|
||||||
|
dlist_push_back(l, 1);
|
||||||
|
dlist_push_back(l, 3);
|
||||||
|
|
||||||
|
printf("Before sort: ");
|
||||||
|
dlist_print(l); // TODO
|
||||||
|
|
||||||
|
dlist_merge_sort(l);
|
||||||
|
|
||||||
|
printf("After sort: ");
|
||||||
|
dlist_print(l); // TODO
|
||||||
|
|
||||||
|
dlist_clear(l);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
Binary file not shown.
Reference in New Issue
Block a user