-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy patht1.cpp
More file actions
40 lines (40 loc) · 980 Bytes
/
Copy patht1.cpp
File metadata and controls
40 lines (40 loc) · 980 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
#include<iostream>
using namespace std;
struct CandyBar
{
char brand[20];
float weight;
int caruli;
};
int main() //糖块信息存储
{
int answer;
CandyBar snack //结构体初始化方法
{
"Mocha Munch",
2.3,
350
};
cout << "Do you need to update the info?\n";
cout << "1 for yes and 0 for no.\n";
cin >> answer;
if(answer == 1)
{
cout << "Please input the new brand,weight and caruli:" << endl;
cin >> snack.brand; //输入的新名称不可以有空格
cin >> snack.weight;
cin >> snack.caruli;
cout << "The latest info of the candy are:\n";
cout << "brand is " << snack.brand << "\n";
cout << "weight = " << snack.weight << "\n";
cout << "caruli = " << snack.caruli << "\n";
}
else
{
cout << "The latest info of the candy are:\n";
cout << "brand is " << snack.brand << "\n";
cout << "weight = " << snack.weight << "\n";
cout << "caruli = " << snack.caruli << "\n";
}
return 0;
}