【C++ Primer Plus习题】4.7

问题:

解答:

cpp 复制代码
#include <iostream>
#include <string>
using namespace std;

typedef struct _Pizza
{
	string companyName;
	float diameter;
	float wieght;
}Pizza;

int main()
{
	Pizza p;
	cout << "请输入披萨的公司名: ";
	getline(cin, p.companyName);
	cout << "请输入披萨的直径: ";
	cin >> p.diameter;
	cout << "请输入披萨的重量: ";
	cin >> p.wieght;
	cout << "披萨公司名:" << p.companyName << endl;
	cout << "披萨直径:" << p.diameter << endl;
	cout << "披萨重量:" << p.wieght << endl;

	return 0;
}

运行结果:

考查点:

  • 结构体的访问

2024年8月24日20:24:59

相关推荐
xiaohe075 分钟前
超详细 Python 爬虫指南
开发语言·爬虫·python
嗑嗑嗑瓜子的猫19 分钟前
Java!它值得!
java·开发语言
STLearner22 分钟前
WSDM 2026 | 时间序列(Time Series)论文总结【预测,表示学习,因果】
大数据·论文阅读·人工智能·深度学习·学习·机器学习·数据挖掘
redaijufeng31 分钟前
网络爬虫学习:应用selenium获取Edge浏览器版本号,自动下载对应版本msedgedriver,确保Edge浏览器顺利打开。
爬虫·学习·selenium
xiaoshuaishuai842 分钟前
C# GPU算力与管理
开发语言·windows·c#
腾科IT教育43 分钟前
零基础快速上岸HCIP,高效学习思路分享
学习·华为认证·hcip·hcip考试·hcip认证
234710212744 分钟前
4.14 学习笔记
笔记·python·学习
醇氧1 小时前
【学习】软件过程模型全解析:从瀑布到敏捷的演进之路
学习·log4j
lsx2024061 小时前
SVN 创建版本库
开发语言
xiaotao1311 小时前
01-编程基础与数学基石:Python错误与异常处理
开发语言·人工智能·python