Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <cstdio>
- #include <set>
- #include <string>
- using namespace std;
- class Time_point{
- public:
- string date, time;
- Time_point(string Date, string Time){
- date = Date;
- time = Time;
- }
- ~Time_point(){
- date.clear();
- time.clear();
- }
- };
- class My_list{
- public:
- Time_point* cur;
- My_list* next;
- void set(My_list* cur){
- My_list* p = this;
- while(p->next)
- p = p->next;
- p->next = cur;
- }
- void get(string date, string time){
- My_list* p = this;
- while(p){
- if(p->cur->date == date && p->cur->time == time){
- cout << "found\n";
- return;
- }
- else
- p = p->next;
- }
- cout << "non-found\n";
- }
- void erase();
- void isEmpty(){
- if(!this)
- cout << "empty\n";
- else
- cout << "non-empty\n";
- }//?
- void print(){
- My_list* p = this;
- while(p){
- cout << p->cur->date << " " << p->cur->time << endl;
- p = p->next;
- }
- }
- My_list(Time_point* Cur){
- cur = Cur;
- next = NULL;
- }
- ~My_list(){
- while(next != NULL){
- delete next->cur;
- delete next;
- }
- } //?
- };
- //correct date-time
- int main(){
- int n; cin >> n;
- My_list *head = NULL;
- head->isEmpty();
- if(n--){
- string date, time;
- cin >> date >> time;
- head = new My_list(new Time_point(date, time));
- }
- //head->print();
- head->isEmpty();
- for(int i = 0; i < n; i++){
- string date, time;
- cin >> date >> time;
- My_list* new_element = new My_list(new Time_point(date, time));
- head->set(new_element);
- }
- head->print();
- head->isEmpty();
- system("pause");
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement