作者 ctqucl [cpp] 2007-01-19 17:31 (点击下载)

  1. // ctqucl AT gmail.com
  2. #include <iostream>
  3. #include<string>
  4. struct car
  5. {
  6. std::string Company;
  7. int Year;
  8. };
  9. int main()
  10. {
  11. using namespace std;
  12. int H_M;
  13. cout<<"How many cars do you wish to catalog? ";
  14. cin>>H_M;
  15. car *user=new car [H_M];
  16. for(int i=0;i<H_M;i++)
  17. {
  18. cout<<"Car #"<<i+1<<":"<<endl;
  19. cout<<"Please enter the make : ";
  20. cin.get(); //why need this?
  21. getline(cin,user[i].Company);
  22. cout<<"Please enter the year made : ";
  23. cin>>user[i].Year;
  24. }
  25. for(int i=0;i<H_M;i++)
  26. {
  27. cout<<user[i].Year<<" "<<user[i].Company<<endl;
  28. }
  29. delete [] user;
  30. }

提交下面的校正或者修改. (点击这里开始一个新的帖子)
姓名: 在 cookie 中记住我的名字

屏幕抓图:(jpeg 或 png)