Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <cstring>
- using namespace std;
- class Film
- {
- char name[100];
- char director[50];
- char genre[50];
- int year;
- public:
- Film()
- {
- strcpy(name,"Star Wars");
- strcpy(director,"George Lucas");
- strcpy(genre,"Sci-Fi");
- year=1977;
- }
- Film(char *n, char *d, char *g, int y)
- {
- strcpy(name,n);
- strcpy(director,d);
- strcpy(genre,g);
- year=y;
- }
- int returnYear()
- {
- return year;
- }
- void Print()
- {
- cout<<"Name: "<<name<<endl;
- cout<<"Director: "<<director<<endl;
- cout<<"Genre: "<<genre<<endl;
- cout<<"Year: "<<year<<endl;
- }
- };
- void print_by_year(Film *f, int n, int year)
- {
- for(int i=0;i<n;i++)
- if(f[i].returnYear()==year)
- f[i].Print();
- }
- int main() {
- int n;
- cin >> n;
- Film f[100];
- for(int i = 0; i < n; ++i) {
- char name[100];
- char director[50];
- char genre[50];
- int year;
- cin >> name;
- cin >> director;
- cin >> genre;
- cin >> year;
- f[i]=Film(name,director,genre,year);
- }
- int year;
- cin >> year;
- print_by_year(f,n,year);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment