Есть код:
#include <iostream>
#include <math.h>
#include <iomanip>
#include <windows.h>
#include <string>
#include <conio.h>
#include <cstdlib>
#include <stdio.h>
#include <stdlib.h>
using namespace std;
//Добавление книги
struct LIBRARY
{
char number[20];
char FIO[30];
char name[30];
int year1;
int year2;
int year3;
int kolvo;
};
struct ITEM
{
LIBRARY* Library;
ITEM* next;
};
ITEM* create(LIBRARY* Library)
{
ITEM* head = new ITEM;
head->Library = Library;
head->next = NULL;
return head;
}
void add(LIBRARY* Library, ITEM* head)
{
while (head->next)
head = head->next;
head->next = new ITEM;
head->next->Library = Library;
head->next->next = NULL;
cout << endl;
}
LIBRARY* make()
{
LIBRARY* Library = new LIBRARY;
cout << "Enter book data:------------------------------------------:\n";
cin.ignore();
cout << "Enter book number: ";
cin.getline(Library->number, 30);
cout << "F.I.O.: ";
cin.getline(Library->FIO, 30);
cout << "Name of the Book: ";
cin.getline(Library->name, 40);
cout << "Enter made year\n";
cout << " Day: "; cin >> Library->year1;
cout << "Mouth: "; cin >> Library->year2;
cout << " Year: "; cin >> Library->year3;
cout << "Enter count of books: ";
cin >> Library->kolvo;
cout << "\n";
return Library;
}
//Вывод на экран список книг
void printLIBRARY(LIBRARY* Library)
{
cout << "\nNumber => " << Library->number;
cout << "\nF.I.O. => " << Library->FIO;
cout << "\nNazvanie => " << Library->name;
cout << "\nYear (DAY) => " << Library->year1;
cout << "\n (MOUTH) => " << Library->year2;
cout << "\n (YEAR) => " << Library->year3;
cout << "\nKolvo => " << Library->kolvo;
cout << "\n\n";
}
//Удаление книги
void del_book()
{
ITEM* head = NULL;
while (true)
{
system("cls");
cout << "1. Back.\n";
cout << "2. Drop name of the book.\n\n";
int action;
cin >> action;
system("CLS");
switch (action)
{
case 1:
{
return;
}
case 2:
{
break;
}
}
_getch();
}
}
//
//МЕНЮ
// Вывести меню пользователю и вернуть номер варианта
int prompt_menu_item()
{
setlocale(LC_ALL, "Rus");
// Выбранный вариант меню
int variant;
cout << "Choose an option\n" << endl;
cout << "1. Add book\n"
<< "2. View the list of Book\n"
<< "3. Delete the book from the list\n"
<< "4. Search for book by year \n"
<< "5. Exit\n" << endl;
cout << ">>> ";
cin >> variant;
if (variant >= 1 && variant <= 5)
return variant;
else
return 0;
}
int main(int argc, char* argv[])
{
ITEM* head = NULL;
do
{
int variant = prompt_menu_item();
switch (variant) {
case 1:
system("cls"); // очищаем экран
cout << "Add book..." << endl;
if (head == NULL)
head = create(make());
else
add(make(), head);
break;
case 2:
system("cls"); // очищаем экран
cout << "View the list of Book..." << endl;
{
int i = 0;
int N = 0;
ITEM* phead = head;
while (head)
{
N++;
head = head->next;
}
LIBRARY* buf;
LIBRARY** pLibrary = new LIBRARY * [N];
head = phead;
while (head)
{
pLibrary[i] = head->Library;
head = head->next;
i++;
}
head = phead;
for (i = 0; i < N; i++)
{
int i1;
i1 = i + 1;
cout << "________________________\n";
cout << i1 << " -Number of Book\n";
printLIBRARY(pLibrary[i]);
}
}
break;
case 3:
system("cls"); // очищаем экран
cout << "Delete the book from the list..." << endl;
del_book();
break;
case 4:
system("cls"); // очищаем экран
cout << "Search for book by year..." << endl;
break;
case 5:
system("cls"); // очищаем экран
cout << "Exit..." << endl;
exit(EXIT_SUCCESS);
break;
default:
cerr << "EeRorrRRooOr...\n" << endl;
}
} while (true);
return 0
}
Не могу сделать удаление книги, нужно вводить название с клавиатуры, и еще прошу помочь с заданием: по запросу выводится информация о книгах, изданных после года, введенного с клавиатуры. Буду благодарен помощи, никак не могу решить