Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <string.h>
- struct Book {
- char title[100];
- int volume;
- int year;
- char author[100];
- };
- struct Magazine {
- char title[100];
- int volume;
- int month;
- int year;
- char editorialBoard[100];
- };
- struct Newspaper {
- char title[100];
- int volume;
- int day;
- int month;
- int year;
- char editor[100];
- };
- struct Book books[10];
- struct Magazine magazines[10];
- struct Newspaper newspapers[10];
- int main(){
- int numBooks,numMagazine,numNewspapers,year;
- printf("Enter the number of books: ");
- scanf("%d",&numBooks);
- printf("Enter number of journals: ");
- scanf("%d",&numMagazine);
- printf("Enter number of newspapers: ");
- scanf("%d",&numNewspapers);
- int i;
- for(i=0;i<numBooks;i++){
- printf("Book %d\n",i+1);
- printf("Title: ");
- scanf("%s",&books[i].title);
- printf("Volume: ");
- scanf("%d",&books[i].volume);
- printf("Year: ");
- scanf("%d",&books[i].year);
- printf("Author: ");
- gets(books[i].author);
- }
- int j;
- for(j=0;j<numMagazine;j++){
- printf("Journal %d\n",j+1);
- printf("Title: ");
- scanf("%s",&magazines[j].title);
- printf("Volume: ");
- scanf("%d",&magazines[j].volume);
- printf("Month: ");
- printf("Year: ");
- scanf("%d",&magazines[j].year);
- scanf("%d",&magazines[j].month);
- printf("Editors: ");
- gets(magazines[j].editorialBoard);
- }
- int k;
- for(k=0;k<numNewspapers;k++){
- printf("Newspaper %d\n",k+1);
- printf("Title: ");
- scanf("%s",&newspapers[k].title);
- printf("Volume: ");
- scanf("%d",&newspapers[k].volume);
- printf("Month: ");
- printf("Year: ");
- printf("Day: ");
- scanf("%d",&newspapers[k].year);
- scanf("%d",&newspapers[k].month);
- scanf("%d",&newspapers[k].day);
- printf("Editors: ");
- gets(newspapers[k].editor);
- }
- printf("\nEnter the year: ");
- scanf("%d",&year);
- int n;
- for(n=0;n<numBooks;++n){
- if(books[i].year == year)
- printf("Book: %s, Author: %s\n",books[i].title,books[i].author);
- }
- int l;
- for(l=0;l<numMagazine;++l){
- if(magazines[j].year == year)
- printf("Magazine: %s, Editors: %s\n",magazines[j].title,books[j].editorialBoard);
- }
- for(int m = 0; m<numNewspapers ; m++){
- if(newspapers[k].year == year){
- printf("Newpaper: %s , Editor: %s \n",newspapers[k].title ,newspapers[k].editor);
- }
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement