#include <iostream>
#include <string>
using namespace std;
struct car
{
string pro;
int year;
};
int main()
{
int num;
cout<<"How many cars do you wish to catalog? ";
(cin>>num).get();//注意将输入后的回车键转换成的换行符读取并丢弃
car *newcar=new car[num];
for(int i=0;i<num;i++)
{
cout<<"Car #"<<i+1<<":"<<endl;
cout<<"Please enter the make: ";
getline(cin,newcar[i].pro);
cout<<"Please enter the year made: ";
(cin>>newcar[i].year).get();//注意将输入后的回车键转换成的换行符读取并丢弃
cout<<"Here is your collection:"<<endl;
for(int j=0;j<num;j++)
cout<<newcar[j].year<<" "<<newcar[j].pro<<endl;
delete [] newcar;//删除开辟的动态空间
system("pause");
return 0;
}