0% found this document useful (0 votes)
82 views13 pages

Raport: "Analiza Prelucrării Structurilor de Date Cu Liste "

This report analyzes processing data structures with linked lists. The report has 7 sections: introduction, task, flowchart, conclusions, bibliography, appendix A and appendix B. The task is to write a program that takes three singly linked lists as input and outputs a new list containing numbers divisible by 2, 4, 8 first, followed by negative odd numbers. The flowchart shows the program logic including creating nodes, printing lists, and functions to select the desired numbers. Conclusions discuss learning about linked lists, their efficiency for adding/removing nodes. Appendix B contains the C program code implementing the task.

Uploaded by

Victoria Etcu
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
82 views13 pages

Raport: "Analiza Prelucrării Structurilor de Date Cu Liste "

This report analyzes processing data structures with linked lists. The report has 7 sections: introduction, task, flowchart, conclusions, bibliography, appendix A and appendix B. The task is to write a program that takes three singly linked lists as input and outputs a new list containing numbers divisible by 2, 4, 8 first, followed by negative odd numbers. The flowchart shows the program logic including creating nodes, printing lists, and functions to select the desired numbers. Conclusions discuss learning about linked lists, their efficiency for adding/removing nodes. Appendix B contains the C program code implementing the task.

Uploaded by

Victoria Etcu
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 13

Universitatea Tehnică a Moldovei

Catedra Automatică și Tehnologii Informaționale

Disciplina: Structuri de date si algoritmi


Varianta 20

Raport
Tema :
“Analiza prelucrării structurilor de date cu liste ”

A efectuat: Sahaidac Maria,TI-173

A verificat: Moțpan Serghei

Chisinău 2018

1
Cuprins:

1. Scopul si obiectivele lucrarii………………………..3


2. Sarcina……………………………………………....4
3. Schema bloc…………………………………………5
4. Concluzii………………………………………….....8
5. Bibliografie………………………………………….9
6. Anexa A…………………………………………….10
7. Anexa B…………………………………………….11

2
Scopul şi obiectivele:

1. de studiat şi însuşit materialul teoretic pentru evidenţierea esenţialului prelucrării


structurilor de date cu liste în elaborarea modelelor soluţiei, analizând exemplele
din text;
2. să se selecteze problemele din compartimentul “3 şi Anexe” şi să se elaboreze
organigramele (pentru funcţiile principale) şi programele cu liste (declarări,
parcurgeri, etc.), pentru aprofundare şi rularea programelor în limbajul C să se
elaboreze scenariile succinte de soluţionare prin respectiva tehnică de prelucrare cu
calculele de verificare şi explicaţii.
3. să se analizeze tehnica modelării şi programării eficiente pentru diverse
compartimente ale diferitor situaţii cu diverse argumentări şi modele de structuri
abstracte, incluzând fişiere cu teste de verificare şi vizualizări.

3
Sarcina:

Scrieţi un program, care din trei liste simplu lănţuite să selecteze într-o
listă nouă mai întîi numerele divizibile la 2, 4 şi 8, apoi numerele
negative impare.

4
Schema bloc:

START

struct Node *head1=NULL;

struct Node *head2=NULL;

struct Node *head3=NULL;

----------------------------
-----
createNode(value,head1);

createNode(value,head2);

createNode(value,head3);

print(head1,head2,head3);

Numerele divizibile la 2 , 4 si 8:

divizibil(head1,head2,head3);

Numerele negative impare:

ImparNegativ(head1,head2);

ImparNegativ(head3);

STOP

5
createNode

Node *newNode;

newNode = ( Node*)malloc(sizeof( Node));

newNode==NULL

newNode->data=value;
return(head);

newNode->next=head;
newNode->next=head;

return(newNode);

STOP

ImparNegativ

Node* aux;

aux=head;

aux!=NULL

aux->data%2!=0&&
aux->data<0

aux->data

aux=aux->next;

STOP 6
print

Node* temp;

head==NULL

temp=head;

Elementele listei: Lista este goala.

temp==NULL

temp->data

temp=temp->next;

STOP

7
Concluzii:
In cadrul acestei lucrari de laborator am facut cunostinta cu stucturile de date de
tip lista si alte structuri de date precum stiva si coada. Am analizat principiul de
formarea a listei,parcurgerea ei,inserarea unui element,stergerea. M-am convins de
eficacitatea listelor prin faptul ca putem adauga un nou nod in lista sau putem
sterge orice nod fie de la inceput, de la sfarsit sau din interiorul listei.

8
Bibliografie:
.
1."Limbajul de programare C". Brian W.Kernighan. Dennis M.Ritchie.
2."C. Tehnici de programare". Florin Munteanu, Gheroghe Musca, Florin Moraru.
3."Arta programarii calculatoarelor". Donald Cnut.
4. Tudor Sorin, Tehnici de programare, 1997.

9
Anexa A
Executia programului :

10
Anexa B:
#include <stdio.h>
#include <stdlib.h>
typedef struct Node {
int data;
struct Node *next;
}Node;

Node *createNode(int value, Node *head) {


Node *newNode;
newNode = ( Node*)malloc(sizeof( Node));

if (newNode==NULL)
return(head);
else {
newNode->data=value;
newNode->next=head;
return(newNode);
}
}
void print( Node *head) {
Node* temp;
if(head==NULL)
printf("Lista goala");
else { temp=head;
printf(" \nElementele listei:",temp->data);
while(temp){
printf(" %d ",temp->data);

11
temp=temp->next;
}
}}

void divizibil(Node *head) {


Node* aux;
aux=head;
while(aux) {
if (aux->data%2==0 && aux->data%4==0 && aux->data%8==0 )

printf(" %d ",aux->data);
aux=aux->next;}}
void ImparNegativ(Node *head) {
Node* aux;
aux=head;
while(aux) {
if (aux->data%2!=0 && aux->data<0 )
printf(" %d ",aux->data);
aux=aux->next;}}
int main () {
struct Node *head1=NULL;
struct Node *head2=NULL;
struct Node *head3=NULL;
printf("\n-----------------------------------------------------");
head1=createNode(-3,head1);
head1=createNode(6,head1);
head1=createNode(9,head1);
head1=createNode(12,head1);
head1=createNode(120,head1);

12
head2=createNode(160,head2);
head2=createNode(63,head2);
head2=createNode(54,head2);
head2=createNode(-45,head2);
head2=createNode(-23,head2);
head3=createNode(-67,head3);
head3=createNode(65,head3);
head3=createNode(-9,head3);
head3=createNode(64,head3);
head3=createNode(144,head3);
print(head1);
print(head2);
print(head3);
printf("\n-----------------------------------------------------");
printf("\nNumerele divizibile la 2 , 4 si 8:\n") ;
divizibil(head1);
divizibil(head2);
divizibil(head3);
printf("\n-----------------------------------------------------");
printf("\nNumerele negative impare:\n");
ImparNegativ(head1);
ImparNegativ(head2);
ImparNegativ(head3);
printf("\n-----------------------------------------------------");}

13

You might also like