#include
using namespace std;
struct car
{
string manu;
int birth_day;
};
int main()
{
cout<<"How many cars do you wish to catalog? ";
int number;
cin>>number;
car pc=new car[number+1];
int i;
for(i=0;i<number;i++)
{
cout<<"Car #"<<i+1<<":"<<endl
<<"Please enter the make: ";
getline(cin,((pc+i)).manu);
cout<<"Please enter the year made: " ;
cin>>(*(pc+i)).birth_day;
}
cout<<"Here is your collection:"<<endl;
for(int j=0;j<i;j++)
{
cout<<(*(pc+j)).birth_day<<" "
<<(*(pc+j)).manu<<endl;
}
}
图片说明