#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;
}
转载于:https://www.cnblogs.com/lynnycy/p/3433732.html