📄 911.cpp
字号:
// How many cars do you wish to catalog? 2
// Car #1:
// Please enter the make: Hudson Hornet
// Please enter the year made: 1952
// Car #2:
// Please enter the make: Kaiser
// Please enter the year made: 1951
// Here is your collection:
// 1952 Hudson Hornet
// 1951 Kaiser
// pe5-6.cpp
#include "iostream"
#include "string"
using namespace std;
struct car
{
string sProducter;
int iProYear;
};
int main()
{
int size;
cout<<"How many cars do you wish to catalog?";
cin>>size;
cin.get();
car *pCar=new car[size];
for (int i=0;i<size;i++)
{
cout<<"Car #"<<i+1<<endl;
cout<<"Please enter the make:";
//cin.get(pCar[i].sProducter,20);
//cin.get();
getline(cin,pCar[i].sProducter);
//cin.get();
cout<<"Please enter the year made:";
cin>>pCar[i].iProYear;
cin.get();
}
cout<<"Here is your collection:"<<endl;
for (i=0;i<size;i++)
{
cout<<pCar[i].iProYear<<" "<<pCar[i].sProducter<<endl;
}
delete []pCar;
return 0;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -