自定义结构体类型用来存储水果的所有信息,

来源:百度知道 编辑:UC知道 时间:2024/06/03 21:01:11
包括水果的编号,名称,和价钱.利用程序实现接收一种水果的信息,并把该水果的信息显示出来.

#include<iostream>
using namespace std;
struct fruit
{
int num;
char name[10];
float price;
};
void main()
{
fruit someone;
cout<<"input the fruit's number,name and price:"<<endl;
cin>>someone.num>>someone.name>>someone.price;
cout<<"the fruit's message about you have inputed are show below:"<<endl;
cout<<"number name price"<<endl;
cout<<someone.num<<" "<<someone.name<<" "<<someone.price<<endl;
}