Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- const int MAXN = 100; // максимально возможное количество книг
- struct book{
- int number;
- char authorName[256];
- char bookName[256];
- int year;
- char publishing[256];
- int countOfPages;
- };
- book books[MAXN];
- int num;
- char authorName[256];
- char bookName[256];
- char publishing[256];
- int countOfPages;
- int year;
- int n;
- void sort(){
- book temp;
- bool ready = false;
- while(!ready){
- ready = true;
- for(int i = 0; i < n-1; i++){
- if(books[i].year < books[i+1].year){
- temp = books[i];
- books[i] = books[i+1];
- books[i+1] = temp;
- ready = false;
- }
- }
- }
- }
- int main(){
- printf("Введите количество книг\n");
- scanf("%d",&n);
- for(int i = 0; i < n; i++){
- printf("Введите регистрационный комер книги\n");
- scanf("%d",&num);
- printf("ФИО автора книги\n");
- scanf("%s",authorName);
- printf("Название\n");
- scanf("%s",bookName);
- printf("Издательство\n");
- scanf("%s",publishing);
- printf("Год издания\n");
- scanf("%d",&year);
- printf("Количество страниц\n");
- scanf("%d",&countOfPages);
- books[i].num = num;
- books[i].authorName = authorName;
- books[i].bookName = bookName;
- books[i].publishing = publishing;
- books[i].year = year;
- books[i].countOfPages = countOfPages;
- }
- printf("Введите год издания\n");
- scanf("%d",&year);
- sort();
- for(int i = 0; i < n; i++){
- if(year > books[i].year){
- // ну здесь вывод информации по книге
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement