Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <cstdlib>
- #define rozmiar 5
- using namespace std;
- /*Zdefiniuj typ strukturalny oraz 100-elementową tablicę
- pozwalającą przechowywać informacje o książkach w bibliotece
- (tytuł, autor, indeks, cena) oraz napisz funkcję, która wyświetli na ekranie
- wszystkie dane tanich książek (tzn. cena<10zł)*/
- struct ksiazka
- {
- char tytul[50];
- char autor[32];
- unsigned int indeks;
- double cena;
- };
- void wypisanie(ksiazka books[]);
- int main()
- {
- ksiazka books[rozmiar];
- for (int i = 0; i < rozmiar; i++)
- {
- books[i].indeks = i + 1;
- cout << "Podaj tytul " << i + 1 << " ksiazki : ";
- cin.getline(books[i].tytul, 50);
- cout << "Podaj autora " << i + 1 << " ksiazki : ";
- cin.getline(books[i].autor, 32);
- cout << "Podaj cene " << i + 1 << " ksiazki : ";
- cin >> books[i].cena;
- cin.ignore(INT_MAX, '\n');
- system("cls");
- }
- wypisanie(books);
- system("pause");
- return 0;
- }
- void wypisanie(ksiazka books[])
- {
- cout << "Wszystkie tanie ksiazki (<10zl) :\n";
- for (int i = 0; i < rozmiar && books[i].cena < 10; i++)
- {
- cout << "\"" << books[i].tytul << "\" autorstwa " << books[i].autor << ". Cena - " << books[i].cena << " zl." << endl;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement