C++ Primer Plus 第4章 习题8
作者:互联网
#include <iostream>
#include <string>
struct Pizza
{
std::string company;
double diameter;
double weight;
};
int main()
{
Pizza* ppizza = new Pizza;
std::cout << "请输入pizza的信息:" << std::endl;
std::cout << "pizza的直径是:" << std::endl;
std::cin >> ppizza->diameter;
std::cin.get();
std::cout << "pizza的生产公司是:" << std::endl;
//std::cin.getline(ppizza->company);
getline(std::cin, ppizza->company, '\n');
std::cout << "pizza的重量为:";
std::cin >> ppizza->weight;
std::cout << "pizza的公司是:" << ppizza->company << ". " << std::endl;
std::cout << "pizza的直径是:" << ppizza->diameter << std::endl;
std::cout << "pizza的重量是:" << ppizza->weight << std::endl;
delete ppizza;
return 0;
}
标签:std,diameter,cout,weight,company,ppizza,Plus,习题,Primer 来源: https://blog.csdn.net/weiyuanzhang123/article/details/117407488