问题:
解答:
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