-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathAssignment-19.cpp
70 lines (69 loc) · 1.45 KB
/
Assignment-19.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
#include<iostream>
using namespace std;
class Book
{
protected:
string title;
string author;
int year;
};
class Publish:public Book
{
protected:
string publisher;
int price;
};
class Library:public Publish
{
public:
void getdetails(string a, string b, string c, int d, int e)
{
title=a;
author=b;
publisher=c;
year=d;
price=e;
}
void printdetails()
{
cout<<title<<" "<<author<<" "<<publisher<<" "<<year<<" "<<price<<"\n";
}
static void book_costly(Library B[],int z)
{
int cost=0,count=0;
for(int i=0;i<z;i++)
{
if(B[i].price<cost)
cost=B[i].price;
}
for(int i=0;i<z;i++)
{
if(B[i].price==cost)
{
count++;
}
}
cout<<count<<"\n";
for(int i=0;i<z;i++)
{
if(B[i].price==cost)
{
B[i].printdetails();
}
}
}
};
int main()
{
string book_title,book_author,book_publisher;
int n,book_price,book_year;
cin>>n;
Library B[n];
for(int i=0;i<n;i++)
{
cin>>book_title>>book_author>>book_publisher>>book_year>>book_price;
B[i].getdetails(book_title,book_author,book_publisher,book_year,book_price);
}
Library::book_costly(B,n);
return 0;
}