64,662
社区成员
发帖
与我相关
我的任务
分享
#include<iostream>
#include<string>
void main()
{
std::string buffer_str;
std::getline(std::cin, buffer_str);
std::cout << buffer_str << std::endl;
}
#include<iostream>
#include<string>
using namespace std;
const int Max=30;
struct car
{
string make;
int year_made;
};
void main()
{
int num_car;int i=0;
cout<<" How many cars do you wish to catolog?____\b\b";
cin>>num_car;
car *c=new car [num_car];
for(i=0;i<num_car;i++)
{
cout<<"Car #"<<(i+1)<<":"<<endl;
cout<<"Please enter the make:";
cin >> c[i].make;// 这么做不可以?
cout<<"Please enter the year made:";
cin>>c[i].year_made;
}
////////
cout<<"\n\aHere is your collection:"<<endl;
for(i=0;i<num_car;i++)
{
cout<<c[i].year_made<<" "<<c[i].make<<endl;
}
delete []c;
/////////
}