Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Для заданной структуры написать функции и вызвать их последовательно в теле функции main:
- include"stdafx.h"
- #include<iostream>
- #include<fstream>
- usingnamespacestd;
- structloop {
- int data;
- loop* next;
- loop* prev;
- };
- voidsaveforward(loop* ploop, fstream&file)
- {
- if (ploop)
- {
- loop * temp = ploop;
- do {
- file<<ploop->data <<" ";
- ploop = ploop->next;
- } while (ploop != temp);
- }
- }
- voidsavebackward(loop* ploop, fstream&file)
- {
- if (ploop)
- {
- loop * temp = ploop;
- do {
- file<<ploop->data <<" ";
- ploop = ploop->prev;
- } while (ploop != temp);
- }
- }
- intmain()
- {
- inti;
- fstream file1;
- file1.open("output.txt", fstream::out);
- file1.clear();
- loop* pl1=newloop;
- pl1->next = pl1;
- pl1->prev = pl1;
- pl1->data = 0;
- saveforward(pl1, file1);
- file1 <<endl;
- savebackward(pl1, file1);
- file1 <<endl;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement