#include<iostream> #define ArSize 50 using namespace std; struct car{ char productor[ArSize]; int year; }; int main() { int n; cout << "How many cars you wish to catalog?"; cin >> n; car *cars = new car [n]; for(int i = 0;i < n;i++) { cin.get(); cout << "Car #" << i + 1 << endl; cout << "Please enter the make:"; cin.getline(cars[i].productor,ArSize); cout << "Please enter the year made:"; cin >> cars[i].year; } cout << "Here is your cellection:" << endl; for(int i = 0;i < n;i++) cout << cars[i].year << " " << cars[i].productor << endl; }
Exercise 5.6
最新推荐文章于 2023-02-21 11:45:12 发布