Advertisement
Josif_tepe

Untitled

Sep 4th, 2021
128
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.87 KB | None | 0 0
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. struct car{
  5.     string brand_name;
  6.     string model;
  7.     int production_date;
  8.     int distance_passed;
  9.    
  10.     car(){
  11.         // empty constructor / default construcotr
  12.     }
  13.     car(string _brand_name, string _model, int _production_date, int _distance_passed) {
  14.         brand_name = _brand_name;
  15.         model = _model;
  16.         production_date = _production_date;
  17.         distance_passed = _distance_passed;
  18.     }
  19. };
  20. int main() {
  21.     int n;
  22.     cin >> n;
  23.    
  24.     car cars[n];
  25.     for(int i = 0; i < n; i++) {
  26.         cin >> cars[i].brand_name >> cars[i].model >> cars[i].production_date >> cars[i].distance_passed;
  27.     }
  28.     for(int i = 0; i < n; i++) {
  29.         cout << cars[i].brand_name << " " << cars[i].model << " " << cars[i].production_date << " " << cars[i].distance_passed << endl;
  30.     }
  31.     return 0;
  32. }
  33.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement