Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "stdafx.h"
- #include <iostream>
- #include <string>
- using namespace std;
- struct autor {
- string imie;
- string nazwisko;
- };
- struct ksiazka {
- string tytul;
- string gatunek;
- string wydawnictwo;
- };
- struct info {
- int strony;
- int rok;
- string rodzaj;
- };
- //*************************************************************************
- void zapis(autor** a, int size);
- void zapis(ksiazka** b, int size);
- void zapis(info** c, int size);
- void odczyt(autor** a, int size);
- void odczyt(ksiazka** b, int size);
- void odczyt(info** c, int size);
- void ini_m(autor** &a, int size);
- void ini_m(ksiazka** &b, int size);
- void ini_m(info** &c, int size);
- void alloc_mem(autor** &a, int size);
- void alloc_mem(ksiazka** &b, int size);
- void alloc_mem(info** &c, int size);
- void delete_a(autor** &a, int size);
- void delete_a(ksiazka** &b, int size);
- void delete_a(info** &c, int size);
- //*************************************************************************
- int main() {
- autor** a = NULL;
- ksiazka** b = NULL;
- info** c = NULL;
- int size;
- cout << "Podaj wielkosc tablicy: ";
- cin >> size;
- cout << "\nWczytywanie danych o ksiazce!\n\n";
- alloc_mem(a, size);
- alloc_mem(b, size);
- alloc_mem(c, size);
- ini_m(a, size);
- zapis(a, size);
- ini_m(b, size);
- zapis(b, size);
- ini_m(c, size);
- zapis(c, size);
- cout << endl << "Odczyt:" << endl;
- odczyt(a, size);
- odczyt(b, size);
- odczyt(c, size);
- delete_a(a, size);
- delete_a(b, size);
- delete_a(c, size);
- getchar();
- getchar();
- return 0;
- }
- //*************************************************************************
- void zapis(autor** a, int size) {
- string imie, nazwisko;
- getchar();
- cout << "Imie autora: ";
- getline(cin, imie);
- cout << "Nazwisko autora: ";
- getline(cin, nazwisko);
- for (int i = 0; i < size; i++) {
- a[i]->imie = imie;
- a[i]->nazwisko = nazwisko;
- }
- }
- //***
- void zapis(ksiazka** b, int size) {
- string tytul, gatunek, wydawnictwo;
- cout << "Tytul ksiazki: ";
- getline(cin, tytul);
- cout << "Gatunek: ";
- getline(cin, gatunek);
- cout << "Wydawnictwo: ";
- getline(cin, wydawnictwo);
- for (int i = 0; i < size; i++) {
- b[i]->tytul = tytul;
- b[i]->gatunek = gatunek;
- b[i]->wydawnictwo = wydawnictwo;
- }
- }
- //***
- void zapis(info** c, int size) {
- int strony, rok;
- string rodzaj;
- cout << "Rodzaj okladki: ";
- getline(cin, rodzaj);
- cout << "Ilosc stron: ";
- cin >> strony;
- cout << "Rok wydania: ";
- cin >> rok;
- for (int i = 0; i < size; i++) {
- c[i]->rodzaj = rodzaj;
- c[i]->strony = strony;
- c[i]->rok = rok;
- }
- }
- //***
- void odczyt(autor** a, int size) {
- for (int i = 0; i < size; i++) {
- cout << a[i]->imie << "\t" << a[i]->nazwisko << "\t";
- }
- }
- //***
- void odczyt(ksiazka** b, int size) {
- for (int i = 0; i < size; i++) {
- cout << b[i]->tytul << "\t" << b[i]->gatunek << "\t" << b[i]->wydawnictwo << "\t";
- }
- }
- //***
- void odczyt(info** c, int size) {
- for (int i = 0; i < size; i++) {
- cout << c[i]->rodzaj << "\t" << c[i]->strony << "\t" << c[i]->rok << "\t";
- }
- }
- //***
- void alloc_mem(autor** &a, int size) {
- a = new autor*[size];
- }
- //***
- void alloc_mem(ksiazka** &b, int size) {
- b = new ksiazka*[size];
- }
- //***
- void alloc_mem(info** &c, int size) {
- c = new info*[size];
- }
- //***
- void ini_m(autor** &a, int size) {
- for (int i = 0; i < size; i++) {
- a[i] = new autor;
- }
- }
- //***
- void ini_m(ksiazka** &b, int size) {
- for (int i = 0; i < size; i++) {
- b[i] = new ksiazka;
- }
- }
- //***
- void ini_m(info** &c, int size) {
- for (int i = 0; i < size; i++) {
- c[i] = new info;
- }
- }
- //***
- void delete_a(autor** &a, int size) {
- for (int i = 0; i<size; i++) {
- delete a[i];
- }
- delete[] a;
- }
- //***
- void delete_a(ksiazka** &b, int size) {
- for (int i = 0; i<size; i++) {
- delete b[i];
- }
- delete[] b;
- }
- //***
- void delete_a(info** &c, int size) {
- for (int i = 0; i<size; i++) {
- delete c[i];
- }
- delete[] c;
- }
- //***
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement