cpp 4.12

来源:互联网 发布:网络转账骗局怎么处理 编辑:程序博客网 时间:2024/05/01 19:49

4.12


#include<iostream>struct inflatable{char name[20];float volume;double price;};int main(){using namespace std;inflatable bouquet ={"sunflowers",0.20,12.49};inflatable choice;cout << "bouquet: " << bouquet.name << " for $";cout << bouquet.price << endl;choice = bouquet;cout << "choice: " << choice.name << " for $";cout << choice.price << endl;system("pause");return 0;}


4.13


#include<iostream>struct inflatable{char name[20];float volume;double price;};int main(){using namespace std;inflatable guests[2] = {{"Bambi", 0.5, 21.99},{"Godzilla", 2000, 565.99}};cout << "The guests " << guests[0].name << " and " << guests[1].name<< "\nhave a combined volume of "<< guests[0].volume + guests[1].volume << " cubic feet.\n";system("pause");return 0;}


0 0