第二次编程练习
#include <iostream>
#include <array>
#include <string>
using namespace std;
struct CandyBar {
string brand;
float weight;
int cal;
};
int main()
{
//1.
array<char, 30> actor1;
char actor2[30]{};
array<float, 13> chuck1;
float chuck2[30]{};
//2.
CandyBar snack{"Mocha Munch", 2.3f, 500};
cout << "Candybar snack's info:\n" << "Name:" << snack.brand
<< "\nWeight:" << snack.weight
<< "g\nKcal:" << snack.cal << "cal." << endl;
//3.
array<float, 3> score;
cout << "Enter three 50-meter sprint results:" << endl;
cin >> score[0];
cout << "Entered." << endl;
cin >> score[1];
cout << "Entered." << endl;
cin >> score[2];
cout << "Number of attempts is " << score.size()
<< ", average score is "
<< (score[0] + score[1] + score[2]) / 3
<< "." << endl;
}