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

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

2013-11-20 15:44 477 查看
#include <iostream>
using namespace std;
struct CandyBar
{
char kind[20];
float weight;
int calory;
};
void Display(CandyBar ca,int n)
{
cout<<"The kind of ca["<<n<<"] is: "<<ca.kind<<endl;
cout<<"The weight of ca["<<n<<"] is: "<<ca.weight<<endl;
cout<<"The calory of ca["<<n<<"] is: "<<ca.calory<<endl;
}
int main()
{
//声明,初始化
CandyBar ca[3]=
{
{"Cindy Tian", 0.5, 366},
{"Pax Congo", 70, 500},
{"Young Yang", 54, 200}
};
Display(ca[0],1);
Display(ca[1],2);
Display(ca[2],3);
system("pause");
return 0;
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐