Ledger Nano X - The secure hardware wallet
SHARE
TWEET

Untitled

a guest Mar 30th, 2020 88 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include<iostream>
  2. #include<cstring>
  3. using namespace std;
  4. class Car{
  5.     public:
  6.     class Person{
  7.     private:
  8.     char name[20];
  9.     char surname[20];
  10.     public:
  11.     Person(){
  12.         strncpy(name,"not specified",13);
  13.         name[13]=0;
  14.         strncpy(surname,"not specified", 13);
  15.         surname[13]=0;
  16.     }
  17.     Person(const char* n="not specified",const char* sn="not specified")
  18.     {
  19.         strncpy(name,n,19);
  20.         name[19]=0;
  21.         strncpy(surname,sn,19);
  22.         name[19]=0;
  23.     }
  24.     void print()
  25.     {
  26.         cout<<name<<" "<<surname<<endl;
  27.     }
  28. };
  29.     class Date{
  30.     private:
  31.     int year;
  32.     int month;
  33.     int day;
  34.     public:
  35.     Date(){}
  36.     Date(int y, int m, int d)
  37.     {
  38.         year=y;
  39.         month=m;
  40.         day=d;
  41.     }
  42.     Date(const Date &copy)
  43.     {
  44.         year=copy.year;
  45.         month=copy.month;
  46.         day=copy.day;
  47.     }
  48.     void print()
  49.     {
  50.         cout<<year<<"."<<month<<"."<<day<<endl;
  51.     }
  52. };
  53.     Car(){price=0;}
  54.     Car(const Car::Person& p, const Car::Date &d, float pr=0):owner(p), date(d)
  55.     {
  56.         price=pr;
  57.     }
  58.     void print(){
  59.         owner.print();
  60.         date.print();
  61.         cout<<"Price: "<<price<<endl;
  62.     }
  63.     int getPrice()
  64.     {
  65.         return price;
  66.     }
  67.     private:
  68.     Person owner;
  69.     Date date;
  70.     float price;
  71. };
  72. void cheaperThan(Car* cars, int numCars, float price)
  73. {
  74.     for(int i=0;i<numCars;i++)
  75.     {
  76.         if(cars[i].getPrice()<price)
  77.             cars[i].print();
  78.     }
  79. }
  80. int main() {
  81.     char name[20];
  82.     char lastName[20];
  83.     int year;
  84.     int month;
  85.     int day;
  86.     float price;
  87.  
  88.     int testCase;
  89.     cin >> testCase;
  90.  
  91.     if (testCase == 1) {
  92.         cin >> name;
  93.         cin >> lastName;
  94.         Car::Person lik(name, lastName);
  95.  
  96.         cin >> year;
  97.         cin >> month;
  98.         cin >> day;
  99.         Car::Date date(year, month, day);
  100.  
  101.         cin >> price;
  102.         Car car(lik, date,  price);
  103.  
  104.         car.print();
  105.     }
  106.     else if (testCase == 2) {
  107.         cin >> name;
  108.         cin >> lastName;
  109.         Car::Person lik(name, lastName);
  110.  
  111.         cin >> year;
  112.         cin >> month;
  113.         cin >> day;
  114.         Car::Date date(Car::Date(year, month, day));
  115.  
  116.         cin >> price;
  117.         Car car(lik, date,  price);
  118.         car.print();
  119.     }
  120.     else {
  121.         int numCars;
  122.         cin >> numCars;
  123.  
  124.         Car cars[10];
  125.         for (int i = 0; i < numCars; i++) {
  126.             cin >> name;
  127.             cin >> lastName;
  128.             Car::Person lik(name, lastName);
  129.  
  130.             cin >> year;
  131.             cin >> month;
  132.             cin >> day;
  133.             Car::Date date(year, month, day);
  134.  
  135.             cin >> price;
  136.             cars[i] = Car(lik, date,  price);
  137.         }
  138.         float priceLimit;
  139.         cin >> priceLimit;
  140.         cheaperThan(cars, numCars, priceLimit);
  141.     }
  142.  
  143.  
  144.     return 0;
  145. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Top