您的位置:首页 > 编程语言 > C语言/C++

编程菜鸟的日记-初学尝试编程-C++ Primer Plus 第4章编程练习8

2013-11-20 16:06 387 查看
#include <iostream>
using namespace std;
const int Size=20;
struct Pizza
{
char company[Size];
double diameter;
double weight;
};
int main()
{
Pizza *piz=new Pizza;//使用new创建动态结构
cout<<"What's the diameter of pizza: ";
cin>>piz->diameter;
cin.get();//读取下一个字符
cout<<"What's the name of pizza company: ";
cin.get(piz->company,Size);
//cin.get();
cout<<"What's the weight of pizza: ";
cin>>piz->weight;
cout<<"diameter: "<<piz->diameter<<endl;
cout<<"company: "<<piz->company<<endl;
cout<<"weight: "<<piz->weight<<endl;
system("pause");
return 0;
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐