欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

结构数组的简单运用

程序员文章站 2022-07-15 08:36:27
...
#include <iostream>
#include <string>
struct inflatable {
	std::string name;
	float volume;
	double price;
};
int main() {
	using namespace std;
	inflatable guest[2]{
		{"Bambi",0.5,21.99},
		{"Godzilla", 2000, 565.99}
	};
	cout << "the guests " << guest[0].name << " and " << guest[1].name
		<< "\nhave a combined volume of " << guest[0].volume + guest[1].volume << " cubic feet.\n";
	return 0;
}

相关标签: C++练习 c++