#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;
}
4.9
最新推荐文章于 2024-10-08 21:35:39 发布