Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*napisać funkcję, która dla listy zaczynającej się pod jakimś adresem i zawierającej dane książek (autor, tytuł, liczba stron)
- a)usuwa książkę autora, podanego jako argument funkcji,
- b)drukuję listę pozostałych książek,
- c)drukuje dane najkrótszych książek,
- d)zwraca dane 1. książki na liście*/
- #include <iostream>
- using namespace std;
- struct Ksia{
- string autor, tytul;
- int strony;
- Ksia *next;
- };
- Ksia f(Ksia *&pl, string autor){
- if(pl==NULL){return;}
- Ksia *pop=new Ksia;
- if (pl->autor==autor){
- Ksia *tmp=new Ksia;
- tmp=pl;
- pl=pl->next;
- delete tmp;
- }else {
- pop=pl;
- while (pop->next->autor!=autor&&pop->next!=NULL){
- pop=pop->next;
- }
- if(pop->next->autor==autor){
- Ksia *akt=new Ksia;
- akt=pop->next;
- pop->next=akt->next;
- delete akt;
- }
- }
- pop=pl;
- while (pop!=NULL){
- cout<<pop->autor<<pop->tytul<<pop->strony<<endl;
- pop=pop->next;
- }
- int min = pl->strony;
- pop=pl;
- while (pop!=NULL){
- if (pop->strony<min){
- min=pop->strony;
- }
- pop=pop->next;
- }
- pop=pl;
- while (pop!=NULL){
- if (pop->strony==min){
- cout<<pop->autor<<pop->tytul<<pop->strony<<endl;
- }
- pop=pop->next;
- }
- Ksia dane;
- dane.autor=pl->autor;
- dane.tytul=pl->tytul;
- dane.strony=pl->strony;
- dane.next=pl->next;
- return dane;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement