703人加入学习
(2人评价)
C++编程系列 第一季编程基础

制作于2018年2月7日

价格 免费
该课程属于 虚幻Unreal - A计划(一年有效期) 请加入后再学习

第二次编程练习

#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;
}

 

[展开全文]

授课教师

SiKi学院老师

课程特色

下载资料(1)
视频(58)

学员动态

阿如 加入学习
盐汽水lL 加入学习
maguslin 加入学习