4.9

#define  _CRT_SECURE_NO_WARNINGS
#include<iostream>
using namespace std;

struct CandyBar
{
	char brand[20];
	double weight;
	int calorie;
};
int main()
{
	CandyBar *snack = new CandyBar;
	cout << "Enter the candy bar's name: ";
	cin.getline(snack->brand, 20);
	cout << "what the weight of this candy bar : ";
	cin >> snack->weight;
	cout << "and how much calorie in one of this : ";
	cin >> snack->calorie;
	cout << "The name of this candy bar is " << (*snack).brand << endl;
	cout << "and the weight of a block of one is " << (*snack).weight << endl;
	cout << "oh! one of a candy bar includes " <<(*snack).calorie << " calorie!";
	return 0;
}
	

你可能感兴趣的:(C++)