Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*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ł)*/
- #include <stdio.h>
- #include <conio.h>
- #include <cstdlib>
- struct BOOK
- {
- char Title[32];
- char Autor[32];
- int Index;
- double Price;
- };
- void search_cheap_books(BOOK books[]);
- int main()
- {
- BOOK TabBOOK[5]; //HowMany = 100
- for(auto Iterator=0; Iterator < 5; Iterator++)
- {
- fseek(stdin, 0, SEEK_END);
- system("cls");
- printf("Podaj tytul ksiazki : ");
- fgets(TabBOOK[Iterator].Title, 32, stdin);
- printf("Podaj autora ksiazki : ");
- fgets(TabBOOK[Iterator].Autor, 32, stdin);
- printf("Podaj cene ksiazki : ");
- scanf("%f", &TabBOOK[Iterator].Price); // Tutaj jest blad, jakis pomysl jak to naprawic ?
- TabBOOK[Iterator].Index = Iterator;
- }
- search_cheap_books(TabBOOK);
- _getch();
- return 0;
- }
- void search_cheap_books(BOOK books[])
- {
- system("cls");
- printf("Ksiazki ponizej 10zl to :\n\n");
- for(auto Iterator = 0; Iterator < 5; Iterator++)
- {
- if(books[Iterator].Price <10 )
- {
- printf("Autor %s\n", books[Iterator].Autor);
- printf("Tytul : %s\n", books[Iterator].Title);
- printf("ID ksiazki : %d\n", books[Iterator].Index);
- printf("Cena : %f\n\n", books[Iterator].Price);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement