Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <iomanip>
- #include <conio.h>
- #include <windows.h>
- using namespace std;
- class file
- {
- public:
- char name[64];
- char content[256];
- int count;
- int day, month, year, min, hour;
- file *next;
- };
- file *add(file *head) //добавление узла в список
- {
- file *pv = new file;
- pv->next = 0;
- cout << "Name of the file: ";
- cin >> pv->name;
- pv->count = 0;
- cout << "Input the content of the file: " << endl;;
- cin >> pv->content;
- SYSTEMTIME st;
- GetSystemTime(&st);
- pv->day = st.wDay;
- pv->month = st.wMonth;
- pv->year = st.wYear;
- pv->hour = st.wHour;
- pv->min = st.wMinute;
- if(head)
- {
- file *temp = head;
- while(temp->next)
- temp = temp->next;
- temp->next = pv;
- }
- else
- head = pv;
- return head;
- }
- void print(file *head) //печать списка
- {
- if(head == 0)
- {
- system("cls");
- cout << "The catalog is empty!";
- }
- else
- {
- while(head != 0){
- cout << head->name << "t" << "t" << head->day << "." << head->month << "." << head->year << " " << head->hour << ":" << head->min << "t" << "t" << head->count << endl;
- head = head->next;
- }
- }
- }
- void open_cont(file *head) //вывод "внутренностей" файла при вводе имени файла
- {
- file *ptr = head;
- char buff[64];
- cout << "Input the name of the file: ";
- cin >> buff;
- bool flag = true;
- while(head != NULL)
- {
- if(strstr(ptr->name, buff))
- {
- system("cls");
- ptr->count++;
- cout << ptr->content;
- flag = false;
- }
- head = head->next;
- }
- if(flag == true) cout << "No match!";
- }
- void clean(file *head) //удаление всего списка
- {
- if(head != 0)
- {
- clean(head->next);
- delete head;
- }
- }
- int main()
- {
- file *head = 0;
- char ckey;
- do
- {
- system("cls");
- cout << "1 - Open filen";
- cout << "2 - Add file to the catalogn";
- cout << "3 - Open the catalogn";
- cout << "5 - Exitn";
- ckey = _getch();
- system("cls");
- if(ckey == '1') open_cont(head);
- else if(ckey == '2') head = add(head);
- else if(ckey == '3')
- {
- cout << "Name" << "t" << "t" << "Date" << "t" << "t" << "t" << "Count" << endl;
- print(head);
- }
- else if(ckey == '5')
- {
- clean(head);
- }
- else continue;
- _getch();
- } while(ckey != '5');
- system("pause");
- return 0;
- }
Add Comment
Please, Sign In to add comment