测试时分开测试
#include <iostream>
#include <cstring>
#include <array>
using namespace std;
int main()
{
//1
// char firname[20] = {0};
// char lastname[20] = {0};
// char grade;
// int age;
// cout << "What is your first name?";
// cin.getline(firname,20);
// cout << "What is your last name?";
// cin.get(lastname,20).get();
// cout << "What letter grade do you deserve?";
// grade = cin.get();
// cout << "What is your age?";
// cin>>age;
// cout<<"Name:"<<lastname<<","<<firname<<endl<<
// "Grade:"<<(char)(grade+1)<<endl<<"age:"<<age;
//2
// const int ArSize = 20;
// string name;
// string dessert;
// cout<<"Enter your name:";
// getline(cin,name);
// cout<<"Enter you favorite dessert:\n";
// getline(cin,dessert);
// cout<<"I have some delicious "<<dessert;
// cout << " for you, "<< name<<".\n";
//3
// char firname[20] = {0};
// char lastname[20] = {0};
// cout << "Enter your first name:";
// cin.getline(firname,20);
// cout << "Enter your last name:";
// cin.get(lastname,20).get();
// strcat(lastname,",");
// strcat(lastname,firname);
// cout<<"Here's the indormation in a single string:"<<lastname;
// return 0;
//4
// string firname;
// string lastname;
// cout << "Enter your first name:";
// getline(cin,firname);
// cout << "Enter your last name:";
// getline(cin,lastname);
// lastname= lastname+","+firname;
// cout<<"Here's the indormation in a single string:"<<lastname;
//5
// struct CandyBar
// {
// string brand;
// float weight;
// int calorie;
// }snack={"Mocha Munch",2.3,350};
// cout<<"品牌:"<<snack.brand<<endl
// <<"重量"<<snack.weight<<endl
// <<"卡路里:"<<snack.calorie<<endl;
//6
// struct CandyBar
// {
// string brand;
// float weight;
// int calorie;
// }snack={"Mocha Munch0",2.3,350},snack1={"Mocha Munch1",2.3,350},snack2={"Mocha Munch2",2.3,350};
// cout<<"品牌:"<<snack.brand<<endl
// <<"重量"<<snack.weight<<endl
// <<"卡路里:"<<snack.calorie<<endl;
// cout<<"品牌1:"<<snack1.brand<<endl
// <<"重量"<<snack1.weight<<endl
// <<"卡路里:"<<snack1.calorie<<endl;
// cout<<"品牌2:"<<snack2.brand<<endl
// <<"重量"<<snack2.weight<<endl
// <<"卡路里:"<<snack2.calorie<<endl;
//7
// typedef struct pizza
// {
// string name;
// float diameter;
// float weight;
// }Pizza;
// Pizza pizza1;
// cout<<"请输入披萨名称:";
// getline(cin,pizza1.name);
// cout<<"请输入披萨直径:";
// cin>>pizza1.diameter;
// cout<<"请输入披萨重量:";
// cin>>pizza1.weight;
// cout<<"披萨名称:"<<pizza1.name<<endl;
// cout<<"披萨重量:"<<pizza1.weight<<endl;
// cout<<"披萨直径:"<<pizza1.diameter<<endl;
//8
// typedef struct pizza
// {
// string name;
// float diameter;
// float weight;
// }Pizza;
// Pizza *pizza1 = new Pizza;
// cout<<"请输入披萨直径:";
// cin>>pizza1->diameter;
// cin.get();
// cout<<"请输入披萨名称:";
// getline(cin,pizza1->name);
// cout<<"请输入披萨重量:";
// cin>>pizza1->weight;
// cout<<"披萨名称:"<<pizza1->name<<endl;
// cout<<"披萨重量:"<<pizza1->weight<<endl;
// cout<<"披萨直径:"<<pizza1->diameter<<endl;
// delete pizza1;
//9
// struct CandyBar
// {
// string brand;
// float weight;
// int calorie;
// };
// // 动态分配一个CandyBar结构体数组
// CandyBar *snack = new CandyBar[3];
// // 为第一个CandyBar实例赋值
// snack[0].brand = "Mocha Munch0";
// snack[0].weight = 2.3;
// snack[0].calorie = 350;
// // 为第二个CandyBar实例赋值
// snack[1].brand = "Mocha Munch1";
// snack[1].weight = 2.3;
// snack[1].calorie = 350;
// // 为第三个CandyBar实例赋值
// snack[2].brand = "Mocha Munch2";
// snack[2].weight = 2.3;
// snack[2].calorie = 350;
// // 打印每个CandyBar实例的详细信息
// cout << "品牌:"<< snack[0].brand << "\n重量:" << snack[0].weight << "\n卡路里:" << snack[0].calorie << endl;
// cout << "品牌1:" << snack[1].brand << "\n重量:" << snack[1].weight << "\n卡路里:" << snack[1].calorie << endl;
// cout << "品牌2:" << snack[2].brand << "\n重量:" << snack[2].weight << "\n卡路里:" << snack[2].calorie << endl;
// // 释放动态分配的内存
// delete[] snack;
//10
array <float,3> arrGrade;
cout<<"请输入三次40米跑成绩(s):";
cin>>arrGrade.at(0)>>arrGrade.at(1)>>arrGrade.at(2);
cout<<"第一次跑的成绩:"<<arrGrade.at(0)<<endl;
cout<<"第二次跑的成绩:"<<arrGrade.at(1)<<endl;
cout<<"第三次跑的成绩:"<<arrGrade.at(2)<<endl;
cout<<"平均成绩:"<<(arrGrade.at(0)+arrGrade.at(1)+arrGrade.at(2))/arrGrade.size();
return 0;
}