Skip to content
This repository has been archived by the owner on Oct 28, 2021. It is now read-only.

Feedback #1

Open
wants to merge 32 commits into
base: feedback
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
71bd377
Setting up GitHub Classroom Feedback
github-classroom[bot] Mar 11, 2021
d6c2ff6
Problema circles
ileanagheo Mar 13, 2021
a861884
Problema a doua
ileanagheo Mar 13, 2021
f8cb077
Ambele ex laborator 2
ileanagheo Mar 20, 2021
7a0d515
Ambele ex laborator 2
ileanagheo Mar 20, 2021
8f5f88f
Merge pull request #2 from sd-pub/lab1
ileanagheo Mar 21, 2021
6e04372
Merge pull request #3 from sd-pub/lab2
ileanagheo Mar 21, 2021
e63362e
laborator 3
ileanagheo Mar 28, 2021
b0c1f30
am reusit sa rezolv problema pe care o aveam la ex 312CAb
ileanagheo Mar 29, 2021
2f0eff2
am reusit sa rezolv problema pe care o aveam la ex 312CAb
ileanagheo Mar 29, 2021
918c4d6
labul 4
ileanagheo Apr 4, 2021
72a2bc0
Merge pull request #4 from sd-pub/lab3
ileanagheo Apr 5, 2021
78edb2b
Merge pull request #5 from sd-pub/lab4
ileanagheo Apr 5, 2021
0e54ca4
laboratorul 5
ileanagheo Apr 10, 2021
193f1fd
Merge pull request #6 from sd-pub/lab5
ileanagheo Apr 17, 2021
6830d06
laboratorul 6
ileanagheo Apr 17, 2021
51b06ff
laborator 7
ileanagheo Apr 26, 2021
49b5694
Merge pull request #7 from sd-pub/lab6
ileanagheo May 10, 2021
184d280
Merge pull request #8 from sd-pub/lab7
ileanagheo May 10, 2021
c96e980
laborator 8
ileanagheo May 11, 2021
cc238e3
ex 313CAa
ileanagheo May 15, 2021
ab9c8dc
task 2 corectat
ileanagheo May 15, 2021
d27f1f9
ex bonus se numeste task3
ileanagheo May 15, 2021
e8abd00
laborator 9
ileanagheo May 18, 2021
94be7bb
laborator 10
ileanagheo May 24, 2021
d628b28
Merge pull request #10 from sd-pub/lab9
ileanagheo May 27, 2021
057c184
Revert "Laborator 9"
ileanagheo May 27, 2021
ee339f5
Merge pull request #12 from sd-pub/revert-10-lab9
ileanagheo May 27, 2021
735b8ca
mainul modificat
ileanagheo May 29, 2021
d96c47a
laborator 11
ileanagheo May 29, 2021
fc35e0f
Merge pull request #11 from sd-pub/lab10
ileanagheo Jun 2, 2021
1d42681
Merge pull request #13 from sd-pub/lab11
ileanagheo Jun 2, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lab/01_recap_pc/skel/Makefile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
CC=clang
CFLAGS=-Wall -Wextra -pedantic -ansi
CFLAGS=-Wall -Wextra -pedantic -ansi -lm
DEBUG=-g -ggdb -O0 -march=native

ELF=circles
Expand Down
Binary file added lab/01_recap_pc/skel/circles
Binary file not shown.
34 changes: 34 additions & 0 deletions lab/01_recap_pc/skel/matrice.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
//Gheorghisor Ileana-Teodora 313CA
#include <stdio.h>
#include <stdlib.h>

int main(void)
{
int n, m, i, j;
int **matrice;
scanf("%d%d", &n, &m);
// Alocarea dinamica a matricei
matrice = (int**)calloc(m, sizeof(int*));
for (i = 0; i < n; i++)
matrice[i]= (int*)calloc(n, sizeof(int));

//Rezolvarea problemei
int x, y;
while(scanf("%d%d", &x, &y)) {
for (i = 0; i < x; i++)
for (j = 0; j < y; j++) {
matrice[i][j]++;
}
}
for (i = 0; i < n; i++) {
for (j = 0; j < m; j++)
printf("%d ", matrice[i][j]);
printf("\n");
}

//Eliberarea memoriei
for( i = 0; i < n; i++)
free(matrice[i]);
free(matrice);

}
Binary file added lab/01_recap_pc/skel/src/.circles.c.swp
Binary file not shown.
28 changes: 25 additions & 3 deletions lab/01_recap_pc/skel/src/circles.c
Original file line number Diff line number Diff line change
@@ -1,10 +1,32 @@
//Gheorghisor Ileana-Teodora 313CA
#include <stdio.h>

#include <math.h>
#include "utils.h"

struct {
int x;
int y;
int r;
} circle[100];

int main()
{
printf("Hello, world!\n");

int N, nr = 0, i, j;
scanf("%d", &N);
for (i = 0; i < N; i++) {
scanf("%d %d %d", &circle[i].x, &circle[i].y, &circle[i].r);
}
for (i = 0; i < N - 1; i++)
for (j = i + 1; j < N; j++) {
double distanta;
distanta = sqrt(pow((circle[i].x - circle[j].x), 2) + pow((circle[i].y - circle[j].y), 2));
if (circle[i].r + circle[j].r >= distanta)
nr++;
else if(circle[i].r > circle[j].r && circle[i].r - circle[j].r >= distanta)
nr++;
else if(circle[i].r < circle[j].r && circle[j].r - circle[i].r >= distanta)
nr++;
}
printf("%d", nr);
return 0;
}
Binary file added lab/02_simple_linked_list/skel/TestLinkedList
Binary file not shown.
187 changes: 166 additions & 21 deletions lab/02_simple_linked_list/skel/src/LinkedList.c
Original file line number Diff line number Diff line change
@@ -1,14 +1,22 @@
/* Gheorghisor Ileana-Teodora, 313CA */
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#include "LinkedList.h"
#include "utils.h"

linked_list_t*
ll_create(unsigned int data_size)

linked_list_t* ll_create(unsigned int data_size)
{
/* TODO */
struct linked_list_t *list;

list = malloc(sizeof(linked_list_t));
list->head = NULL;
list->data_size = data_size;
list->size = 0;

return list;
}

/*
Expand All @@ -18,10 +26,54 @@ ll_create(unsigned int data_size)
* pozitia n=0). Daca n >= nr_noduri, noul nod se adauga la finalul listei. Daca
* n < 0, eroare.
*/
void
ll_add_nth_node(linked_list_t* list, unsigned int n, const void* new_data)
void ll_add_nth_node(linked_list_t* list, unsigned int n, const void* new_data)
{
/* TODO */
/* Daca n < 0, afisez eroare. */
if (n < 0) {
printf("%s\n", "Eroare.\n");
}
else {
struct ll_node_t *new, *curr, *nextt;

if (list == NULL) {
return;
}
new = (struct ll_node_t*)malloc(sizeof(struct ll_node_t));
new->data = (void*)malloc(sizeof(void*));

/* Daca n >= nr_noduri, adaug la final. */
if (n >= list->size && list->size != 0) {
memcpy(new->data, new_data, sizeof(void*));
new->next = NULL;
curr = list->head;
while (curr->next != NULL) {
curr = curr->next;
}
curr->next = new;
list->size++;

} else if (n > 0 && list->size != 0) {
/* Altfel, inserez nodul intre curr si nextt, pe pozitia n. */
unsigned int i = 0;
curr = list->head;
while (curr->next != NULL && i < n) {
curr = curr->next;
i++;
}
memcpy(new->data, new_data, sizeof(void*));
nextt = curr->next;
curr->next = new;
new->next = nextt;
list->size++;

} else if (n == 0 || list->size == 0) {
/* Pentru primul nod, n = 0. */
memcpy(new->data, new_data, sizeof(void*));
new->next = list->head;
list->head = new;
list->size++;
}
}
}

/*
Expand All @@ -32,20 +84,68 @@ ll_add_nth_node(linked_list_t* list, unsigned int n, const void* new_data)
* nod proaspat eliminat din lista. Este responsabilitatea apelantului sa
* elibereze memoria acestui nod.
*/
ll_node_t*
ll_remove_nth_node(linked_list_t* list, unsigned int n)
ll_node_t* ll_remove_nth_node(linked_list_t* list, unsigned int n)
{
/* TODO */
/* Daca n < 0, afisez eroare. */
if (n < 0) {
printf("%s\n", "Eroare.\n");
return NULL;
}
else {
struct ll_node_t *last, *prev, *curr, *first;

if (list == NULL || list->head == NULL) {
return NULL;
}

/* Daca n >= nr_noduri - 1, sterg ultimul nod. */
if (n >= list->size - 1) {
if(list->size == 1) {
list->size--;
return(list->head);
}
last = list->head->next;
prev = list->head;
while (last->next != NULL) {
prev = last;
last = last->next;
}
prev->next = NULL;
list->size--;
return last;

} else if (n != 0) {
/* Altfel, sterg nodul de pe pozitia n (cu exceptia n = 0). */
unsigned int i = 1;
prev = list->head;
curr = list->head->next;
while (curr->next != NULL && i < n) {
prev = curr;
curr = curr->next;
i++;
}
prev->next = curr->next;
list->size--;
return curr;

} else if (n == 0) {
/* Sterg primul nod pt n = 0. */
first = list->head;
list->head = first->next;
list->size--;
return first;
}
}
return NULL;
}

/*
* Functia intoarce numarul de noduri din lista al carei pointer este trimis ca
* parametru.
*/
unsigned int
ll_get_size(linked_list_t* list)
unsigned int ll_get_size(linked_list_t* list)
{
/* TODO */
return (unsigned int)list->size;
}

/*
Expand All @@ -54,22 +154,35 @@ ll_get_size(linked_list_t* list)
* NULL valoarea pointerului la care pointeaza argumentul (argumentul este un
* pointer la un pointer).
*/
void
ll_free(linked_list_t** pp_list)
void ll_free(linked_list_t** pp_list)
{
/* TODO */
if (*pp_list == NULL || pp_list == NULL) {
return;
}
while (ll_get_size(*pp_list) > 0) {
free(ll_remove_nth_node(*pp_list, 0));
}
free(*pp_list);
*pp_list = NULL;
}

/*
* Atentie! Aceasta functie poate fi apelata doar pe liste ale caror noduri STIM
* ca stocheaza int-uri. Functia afiseaza toate valorile int stocate in nodurile
* din lista inlantuita separate printr-un spatiu.
*/
void
ll_print_int(linked_list_t* list)
void ll_print_int(linked_list_t* list)
{
/* TODO */
struct ll_node_t *curr;

if (list == NULL) {
return;
}
curr = list->head;
while (curr != NULL) {
printf("%u ", *((unsigned int*)curr->data));
curr = curr->next;
}
printf("\n");
}

Expand All @@ -78,10 +191,42 @@ ll_print_int(linked_list_t* list)
* ca stocheaza string-uri. Functia afiseaza toate string-urile stocate in
* nodurile din lista inlantuita, separate printr-un spatiu.
*/
void
ll_print_string(linked_list_t* list)
void ll_print_string(linked_list_t* list)
{
/* TODO */
struct ll_node_t *curr;

if (list == NULL) {
return;
}
curr = list->head;
while (curr != NULL) {
printf("%s ", (char*)curr->data);
curr = curr->next;
}
printf("\n");
}

/* Functia de la exercitiul 2*/
void ll_ex2(linked_list_t* list)
{
unsigned int i = 0;
struct linked_list_t *indici_pari, *indici_impari;
struct ll_node_t *curr;

indici_pari = ll_create(sizeof(int));
indici_impari = ll_create(sizeof(int));
curr = list->head;

while (curr != NULL) {
ll_add_nth_node(indici_pari, i, curr->data);
curr = curr->next;
i++;
if (curr != NULL) {
ll_add_nth_node(indici_impari, i, curr->data);
curr = curr->next;
i++;
}
}
ll_print_int(indici_pari);
ll_print_int(indici_impari);
}
21 changes: 7 additions & 14 deletions lab/02_simple_linked_list/skel/src/LinkedList.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,25 +16,18 @@ struct linked_list_t
unsigned int size;
};

linked_list_t*
ll_create(unsigned int data_size);
linked_list_t* ll_create(unsigned int data_size);

void
ll_add_nth_node(linked_list_t* list, unsigned int n, const void* data);
void ll_add_nth_node(linked_list_t* list, unsigned int n, const void* data);

ll_node_t*
ll_remove_nth_node(linked_list_t* list, unsigned int n);
ll_node_t* ll_remove_nth_node(linked_list_t* list, unsigned int n);

unsigned int
ll_get_size(linked_list_t* list);
unsigned int ll_get_size(linked_list_t* list);

void
ll_free(linked_list_t** pp_list);
void ll_free(linked_list_t** pp_list);

void
ll_print_int(linked_list_t* list);
void ll_print_int(linked_list_t* list);

void
ll_print_string(linked_list_t* list);
void ll_print_string(linked_list_t* list);

#endif /* __LINKED_LIST_H_ */
Binary file added lab/02_simple_linked_list/skel/src/LinkedList.o
Binary file not shown.
8 changes: 5 additions & 3 deletions lab/02_simple_linked_list/skel/src/TestLinkedList.c
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@

#define MAX_STRING_SIZE 64

int
main()
int main()
{
linked_list_t* linkedList;
int is_int = 0;
Expand Down Expand Up @@ -35,7 +34,7 @@ main()
}
if (strcmp(command, "remove") == 0) {
scanf("%ld", &pos);
ll_remove_nth_node(linkedList, pos);
free(ll_remove_nth_node(linkedList, pos));
}
if (strcmp(command, "print") == 0) {
if (is_int == 1) {
Expand All @@ -49,6 +48,9 @@ main()
ll_free(&linkedList);
break;
}
if (strcmp(command, "ex2") == 0) {
ll_ex2(linkedList);
}
}
return 0;
}
Binary file not shown.
Loading