Professional Documents
Culture Documents
Курсач - програмування на С
Курсач - програмування на С
КУРСОВА РОБОТА
ЗАВДАННЯ
НА КУРСОВУ РОБОТУ
1. Тема роботи
«Програмування динамічної структури даних – черга»
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
if (head == NULL) {
head = new_node;
tail = new_node;
} else {
tail->next = new_node;
tail = new_node;
}
}
void dequeue() {
if (head == NULL) {
printf("Queue is empty.\n");
return;
}
if (head == NULL) {
tail = NULL;
}
free(temp);
5
}
void display_all() {
Waste *current = head;
current = current->next;
}
}
return total_cost;
}
return total_quantity;
}
void sort_by_quantity() {
if (head == NULL) {
return;
}
int swapped;
Waste *current;
Waste *last = NULL;
do {
swapped = 0;
current = head;
7
void sort_by_cost() {
if (head == NULL) {
return;
}
int swapped;
Waste *current;
Waste *last = NULL;
do {
swapped = 0;
current = head;
int main() {
int choice;
do {
printf("1. Add data\n");
printf("2. Remove data\n");
printf("3. Update data\n");
printf("4. Display all data\n");
printf("5. Display companies by waste and date\n");
printf("6. Calculate disposal cost\n");
printf("7. Display companies by street\n");
printf("8. Calculate total waste quantity\n");
8
printf("9. Sort by quantity\n");
printf("10. Sort by cost\n");
printf("0. Exit\n");
printf("Enter your choice: ");
scanf("%d", &choice);
switch (choice) {
case 1: {
Waste data;
enqueue(data);
break;
}
case 2: {
dequeue();
break;
}
case 3: {
int company_code;
Waste new_data;
update_data(company_code, new_data);
break;
}
case 4:
display_all();
break;
case 5: {
int waste_code;
char date[20];
display_companies_by_waste_and_date(waste_code, date);
break;
}
case 6: {
10
int company_code, waste_code;
display_companies_by_street(street);
break;
}
case 8: {
int company_code;
char start_date[20], end_date[20];
return 0;
11
}