首页 > 其他分享 >实验四

实验四

时间:2024-11-19 15:08:24浏览次数:1  
标签:std const int void 实验 date include

实验任务二:

#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <numeric>
#include <iomanip>

using std::vector;
using std::string;
using std::cin;
using std::cout;
using std::endl;

class GradeCalc: public vector<int> {
public:
    GradeCalc(const string &cname, int size);      
    void input();                             // 录入成绩
    void output() const;                      // 输出成绩
    void sort(bool ascending = false);        // 排序 (默认降序)
    int min() const;                          // 返回最低分
    int max() const;                          // 返回最高分
    float average() const;                    // 返回平均分
    void info();                              // 输出课程成绩信息 

private:
    void compute();     // 成绩统计

private:
    string course_name;     // 课程名
    int n;                  // 课程人数
    vector<int> counts = vector<int>(5, 0);      // 保存各分数段人数([0, 60), [60, 70), [70, 80), [80, 90), [90, 100]
    vector<double> rates = vector<double>(5, 0); // 保存各分数段比例 
};

GradeCalc::GradeCalc(const string &cname, int size): course_name{cname}, n{size} {}   

void GradeCalc::input() {
    int grade;

    for(int i = 0; i < n; ++i) {
        cin >> grade;
        this->push_back(grade);
    } 
}  

void GradeCalc::output() const {
    for(auto ptr = this->begin(); ptr != this->end(); ++ptr)
        cout << *ptr << " ";
    cout << endl;
} 

void GradeCalc::sort(bool ascending) {
    if(ascending)
        std::sort(this->begin(), this->end());
    else
        std::sort(this->begin(), this->end(), std::greater<int>());
}  

int GradeCalc::min() const {
    return *std::min_element(this->begin(), this->end());
}  

int GradeCalc::max() const {
    return *std::max_element(this->begin(), this->end());
}    

float GradeCalc::average() const {
    return std::accumulate(this->begin(), this->end(), 0) * 1.0 / n;
}   

void GradeCalc::compute() {
    for(int grade: *this) {
        if(grade < 60)
            counts.at(0)++;
        else if(grade >= 60 && grade < 70)
            counts.at(1)++;
        else if(grade >= 70 && grade < 80)
            counts.at(2)++;
        else if(grade >= 80 && grade < 90)
            counts.at(3)++;
        else if(grade >= 90)
            counts.at(4)++;
    }

    for(int i = 0; i < rates.size(); ++i)
        rates.at(i) = counts.at(i) * 1.0 / n;
}

void GradeCalc::info()  {
    cout << "课程名称:\t" << course_name << endl;
    cout << "排序后成绩: \t";
    sort();  output();
    cout << "最高分:\t" << max() << endl;
    cout << "最低分:\t" << min() << endl;
    cout << "平均分:\t" << std::fixed << std::setprecision(2) << average() << endl;
    
    compute();  // 统计各分数段人数、比例

    vector<string> tmp{"[0, 60)  ", "[60, 70)", "[70, 80)","[80, 90)", "[90, 100]"};
    for(int i = tmp.size()-1; i >= 0; --i)
        cout << tmp[i] << "\t: " << counts[i] << "人\t" 
             << std::fixed << std::setprecision(2) << rates[i]*100 << "%" << endl; 
} 

  

#include "GradeCalc.hpp"
#include <iomanip>

void test() {
    int n;
    cout << "输入班级人数: ";
    cin >> n;

    GradeCalc c1("OOP", n);

    cout << "录入成绩: " << endl;;
    c1.input();
    cout << "输出成绩: " << endl;
    c1.output();

    cout << string(20, '*') + "课程成绩信息"  + string(20, '*') << endl;
    c1.info();
}

int main() {
    test();
}

  

 

问题一:成绩存储在vector类中;通过vector中的接口来访问;vector的push_back()接口 问题二:求平均数,1.0是将数据转换成double类型,防止整数除法时丢失数据 问题三:没有对输入成绩进行合法性检查     实验任务三:
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <numeric>
#include <iomanip>

using std::vector;
using std::string;
using std::cin;
using std::cout;
using std::endl;

class GradeCalc {
public:
    GradeCalc(const string &cname, int size);      
    void input();                             // 录入成绩
    void output() const;                      // 输出成绩
    void sort(bool ascending = false);        // 排序 (默认降序)
    int min() const;                          // 返回最低分
    int max() const;                          // 返回最高分
    float average() const;                    // 返回平均分
    void info();                              // 输出课程成绩信息 

private:
    void compute();     // 成绩统计

private:
    string course_name;     // 课程名
    int n;                  // 课程人数
    vector<int> grades;     // 课程成绩
    vector<int> counts = vector<int>(5, 0);      // 保存各分数段人数([0, 60), [60, 70), [70, 80), [80, 90), [90, 100]
    vector<double> rates = vector<double>(5, 0); // 保存各分数段比例 
};

GradeCalc::GradeCalc(const string &cname, int size): course_name{cname}, n{size} {}   

void GradeCalc::input() {
    int grade;

    for(int i = 0; i < n; ++i) {
        cin >> grade;
        grades.push_back(grade);
    } 
}  

void GradeCalc::output() const {
    for(int grade: grades)
        cout << grade << " ";
    cout << endl;
} 

void GradeCalc::sort(bool ascending) {
    if(ascending)
        std::sort(grades.begin(), grades.end());
    else
        std::sort(grades.begin(), grades.end(), std::greater<int>());
        
}  

int GradeCalc::min() const {
    return *std::min_element(grades.begin(), grades.end());
}  

int GradeCalc::max() const {
    return *std::max_element(grades.begin(), grades.end());
}    

float GradeCalc::average() const {
    return std::accumulate(grades.begin(), grades.end(), 0) * 1.0 / n;
}   

void GradeCalc::compute() {
    for(int grade: grades) {
        if(grade < 60)
            counts.at(0)++;
        else if(grade >= 60 && grade < 70)
            counts.at(1)++;
        else if(grade >= 70 && grade < 80)
            counts.at(2)++;
        else if(grade >= 80 && grade < 90)
            counts.at(3)++;
        else if(grade >= 90)
            counts.at(4)++;
    }

    for(int i = 0; i < rates.size(); ++i)
        rates.at(i) = counts.at(i) *1.0 / n;
}

void GradeCalc::info()  {
    cout << "课程名称:\t" << course_name << endl;
    cout << "排序后成绩: \t";
    sort();  output();
    cout << "最高分:\t" << max() << endl;
    cout << "最低分:\t" << min() << endl;
    cout << "平均分:\t" << std::fixed << std::setprecision(2) << average() << endl;
    
    compute();  // 统计各分数段人数、比例

    vector<string> tmp{"[0, 60)  ", "[60, 70)", "[70, 80)","[80, 90)", "[90, 100]"};
    for(int i = tmp.size()-1; i >= 0; --i)
        cout << tmp[i] << "\t: " << counts[i] << "人\t" 
             << std::fixed << std::setprecision(2) << rates[i]*100 << "%" << endl; 
} 

  

#include "GradeCalc.hpp"
#include <iomanip>

void test() {
    int n;
    cout << "输入班级人数: ";
    cin >> n;

    GradeCalc c1("OOP", n);

    cout << "录入成绩: " << endl;;
    c1.input();
    cout << "输出成绩: " << endl;
    c1.output();

    cout << string(20, '*') + "课程成绩信息"  + string(20, '*') << endl;
    c1.info();
}

int main() {
    test();
}

  

 

问题一:存储在派生类定义的vector容器中;通过vector接口访问; 问题二:类可以多种设计,可以继承,使用基类元素,也可以自行封装     实验任务四:
#include <iostream>
#include <string>
#include <limits>

using namespace std;

void test1() {
    string s1, s2;
    cin >> s1 >> s2;  // cin: 从输入流读取字符串, 碰到空白符(空格/回车/Tab)即结束
    cout << "s1: " << s1 << endl;
    cout << "s2: " << s2 << endl;
}

void test2() {
    string s1, s2;
    getline(cin, s1);  // getline(): 从输入流中提取字符串,直到遇到换行符
    getline(cin, s2);
    cout << "s1: " << s1 << endl;
    cout << "s2: " << s2 << endl;
}

void test3() {
    string s1, s2;
    getline(cin, s1, ' '); //从输入流中提取字符串,直到遇到指定分隔符
    getline(cin, s2);
    cout << "s1: " << s1 << endl;
    cout << "s2: " << s2 << endl;
}

int main() {
    cout << "测试1: 使用标准输入流对象cin输入字符串" << endl;
    test1();
    cout << endl;

    cin.ignore(numeric_limits<streamsize>::max(), '\n');

    cout << "测试2: 使用函数getline()输入字符串" << endl;
    test2();
    cout << endl;

    cout << "测试3: 使用函数getline()输入字符串, 指定字符串分隔符" << endl;
    test3();
}

  

#include <iostream>
#include <string>
#include <vector>
#include <limits>

using namespace std;

void output(const vector<string> &v) {
    for(auto &s: v)
        cout << s << endl;
}

void test() {
    int n;
    while(cout << "Enter n: ", cin >> n) {
        vector<string> v1;

        for(int i = 0; i < n; ++i) {
            string s;
            cin >> s;
            v1.push_back(s);
        }

        cout << "output v1: " << endl;
        output(v1); 
        cout << endl;
    }
}

int main() {
    cout << "测试: 使用cin多组输入字符串" << endl;
    test();
}

  

#include <iostream>
#include <string>
#include <vector>
#include <limits>

using namespace std;

void output(const vector<string> &v) {
    for(auto &s: v)
        cout << s << endl;
}

void test() {
    int n;
    while(cout << "Enter n: ", cin >> n) {
        cin.ignore(numeric_limits<streamsize>::max(), '\n');

        vector<string> v2;

        for(int i = 0; i < n; ++i) {
            string s;
            getline(cin, s);
            v2.push_back(s);
        }
        cout << "output v2: " << endl;
        output(v2); 
        cout << endl;
    }
}

int main() {
    cout << "测试: 使用函数getline()多组输入字符串" << endl;
    test();
}

  

 

 

 问题一:读取缓冲区中的换行符,使下一次字符可以正常输入

问题二:多次输入,并且在输入n后去掉缓冲区中的换行符,以至于正常输入

实验任务五:

#include "C:\Users\29114\source\repos\MAJORCPP\grm.hpp"
#include <iostream>

using std::cout;
using std::endl;

void test1() {
    GameResourceManager<float> HP_manager(99.99);
    cout << "当前生命值: " << HP_manager.get() << endl;
    HP_manager.update(9.99);
    cout << "增加9.99生命值后, 当前生命值: " << HP_manager.get() << endl;
    HP_manager.update(-999.99);
    cout <<"减少999.99生命值后, 当前生命值: " << HP_manager.get() << endl;
}

void test2() {
    GameResourceManager<int> Gold_manager(100);
    cout << "当前金币数量: " << Gold_manager.get() << endl;
    Gold_manager.update(50);
    cout << "增加50个金币后, 当前金币数量: " << Gold_manager.get() << endl;
    Gold_manager.update(-99);
    cout <<"减少99个金币后, 当前金币数量: " << Gold_manager.get() << endl;
}


int main() {
    cout << "测试1: 用float类型对类模板GameResourceManager实例化" << endl;
    test1();
    cout << endl;

    cout << "测试2: 用int类型对类模板GameResourceManager实例化" << endl;
    test2();
}

  

#include <iostream>
#include <string>
using namespace std;
template<typename T>
class GameResourceManager {
private:
	T resource;
public:
	GameResourceManager(T a);
	T get();
	void update(T a);
};
template<typename T>
GameResourceManager<T>::GameResourceManager(T a) :resource{ a } {}
template<typename T>
T GameResourceManager<T>::get() {
	return resource;
}
template<typename T>
void GameResourceManager<T>::update(T a) {
	resource = resource + a < 0 ? 0 : resource + a;
}

  

 

实验任务6

#include <iostream>
#include <string>
#include<iomanip>
using namespace std;
class info {
private:
	string nickname;
	string contact;
	string city;
	int n;
public:
	info(string name, string con, string city, int n);
	info() {};
	void display();
};
info::info(string name, string con, string city, int n) :nickname{ name }, contact{ con }, city{ city }, n{ n } {}

void info::display() {
	cout << "---------------------------------------------------" << endl;
	cout << left << setw(15) << "昵称:" << left << setw(15) <<nickname<< endl;
	cout << left << setw(15) << "联系方式:" << left << setw(15) << contact << endl;
	cout << left << setw(15) << "所在城市:" << left << setw(15) << city << endl;
	cout << left << setw(15) << "预定人数:" << left << setw(15) << n << endl;
}

  

#include<iostream>
#include"c:/Users/29114/source/repos/MAJORCPP/info.hpp"
using namespace std;
#include<iomanip>
#include<vector>
#include<limits>
int main() {
	const int capacity = 100;
	cout << "录入用户信息:" << endl;
	cout << left << setw(15) << "昵称" << left << setw(20) << "联系方式" << left << setw(15) << "所在城市" << left << setw(15) << "预定参加人数" << endl;
	vector<info> audience_list;
	
	string nickname, city, contact;
	int n;
	int now_cap = 0;
	while (true) {
		if (!(cin >> nickname >> contact >> city >> n))
			break;
		
		if (now_cap + n > capacity)
		{
			cout << "对不起,只剩80个位置。" << endl;
			cout << "1.输入u,更新预约信息" << endl << "2.输入q,退出预定" << endl << "你的选择:" << endl;
			string a;
			cin >> a;
			if (a == "u")
			{
				cout << "请重新输入预约信息:" << endl;
				cin >> nickname >> contact >> city >> n;
				audience_list.push_back(info(nickname, contact, city, n));
			}
			else if (a == "q")
				break;
		}
		else {
			now_cap += n;
			audience_list.push_back(info(nickname, contact, city, n));
		}
	}
	cout << "截至目前,一共有" << now_cap << "位听众预约。预约听众信息如下:" << endl;
	for (info& i : audience_list)
		i.display();
}

实验任务七:

#ifndef __DATE_H__
#define __DATE_H__

class Date {
private:
    int year;
    int month;
    int day;
    int totalDays;
public:
    Date(int year, int month, int day);
    int getYear() const { return year; }
    int getMonth() const { return month; }
    int getDay() const { return day; }
    int getMaxDay() const;
    bool isLeapYear() const {
        return year % 4 == 0 && year % 100 != 0 || year % 400 == 0;
    }
    void show() const;

    int distance(const Date& date) const {
        return totalDays - date.totalDays;
    }
};

#endif //__DATE_H__
#include "date.h"
#include <iostream>
#include <cstdlib>
using namespace std;
namespace {
    const int DAYS_BEFORE_MONTH[] = { 0,31,59,90,120,151,181,212,243,273,304,334,365 };
}

Date::Date(int year, int month, int day) : year(year), month(month), day(day) {
    if (day <= 0 || day > getMaxDay()) {
        cout << "Invalid date:";
        show();
        cout << endl;
        exit(1);
    }
    int years = year - 1;
    totalDays = years * 365 + years / 4 - years / 100 + years / 400 + DAYS_BEFORE_MONTH[month - 1] + day;
    if (isLeapYear() && month > 2) totalDays++;
}

int Date::getMaxDay() const {
    if (isLeapYear() && month == 2)
        return 29;
    else
        return DAYS_BEFORE_MONTH[month] - DAYS_BEFORE_MONTH[month - 1];
}

void Date::show() const {
    cout << getYear() << "-" << getMonth() << "-" << getDay();
}

  

#pragma once
#ifndef ACCUMULATOR_H
#define ACCUMULATOR_H

#include "date.h"

class Accumulator {
private:
    Date lastDate;
    double value;
    double sum;

public:
    Accumulator(const Date& date, double value) : lastDate(date), value(value), sum(0) {
    }

    double getSum(const Date& date) const {
        return sum + value * date.distance(lastDate);
    }

    void change(const Date& date, double value) {
        sum = getSum(date);
        lastDate = date;
        this->value = value;
    }

    void reset(const Date& date, double value) {
        lastDate = date;
        this->value = value;
        sum = 0;
    }
};

#endif // ACCUMULATOR_H

  

#pragma once
#ifndef ACCOUNT_H
#define ACCOUNT_H

#include "date.h"
#include "accumulator.h"
#include <string>

class Account {
private:
    std::string id;
    double balance;
    static double total;

protected:
    Account(const Date& date, const std::string& id);
    void record(const Date& date, double amount, const std::string& desc);
    void error(const std::string& msg) const;

public:
    const std::string& getId() const;
    double getBalance() const;
    static double getTotal();

    void show() const;
};

class SavingsAccount : public Account {
private:
    Accumulator acc;
    double rate;

public:
    SavingsAccount(const Date& date, const std::string& id, double rate);
    double getRate() const;

    void deposit(const Date& date, double amount, const std::string& desc);
    void withdraw(const Date& date, double amount, const std::string& desc);
    void settle(const Date& date);
};

class CreditAccount : public Account {
private:
    Accumulator acc;
    double credit;
    double rate;
    double fee;
    double getDebt() const;

public:
    CreditAccount(const Date& date, const std::string& id, double credit, double rate, double fee);
    double getCredit() const;
    double getRate() const;
    double getAvailableCredit() const;

    void deposit(const Date& date, double amount, const std::string& desc);
    void withdraw(const Date& date, double amount, const std::string& desc);
    void settle(const Date& date);
    void show() const;
};

#endif // ACCOUNT_H

  

#include "account.h"
#include <cmath>
#include <iostream>
using namespace std;

double Account::total = 0;

Account::Account(const Date& date, const string& id) : id(id), balance(0) {
    date.show(); 
    cout << "\t#" << id << " created" << endl;
}

void Account::record(const Date& date, double amount, const string& desc) {
    amount = floor(amount * 100 + 0.5) / 100; // 四舍五入到两位小数
    balance += amount;
    total += amount;
    date.show();
    cout << "\t#" << id << "\t" << amount << "\t" << balance << "\t" << desc << endl;
}

void Account::show() const {
    cout << id << "\tBalance:" << balance;
}

void Account::error(const string& msg) const {
    cout << "Error(#" << id << "):" << msg << endl;
}

SavingsAccount::SavingsAccount(const Date& date, const string& id, double rate)
    : Account(date, id), rate(rate), acc(date, 0) {}

void SavingsAccount::deposit(const Date& date, double amount, const string& desc) {
    record(date, amount, desc);
    acc.change(date, getBalance());
}

void SavingsAccount::withdraw(const Date& date, double amount, const string& desc) {
    if (amount > getBalance()) {
        error("not enough money");
    } else {
        record(date, -amount, desc);
        acc.change(date, getBalance());
    }
}

void SavingsAccount::settle(const Date& date) {
    double interest = acc.getSum(date) * rate / date.distance(Date(date.getYear() - 1, 1, 1));
    if (interest != 0) record(date, interest, "interest");
    acc.reset(date, getBalance());
}

CreditAccount::CreditAccount(const Date& date, const string& id, double credit, double rate, double fee)
    : Account(date, id), credit(credit), rate(rate), fee(fee), acc(date, 0) {}

void CreditAccount::deposit(const Date& date, double amount, const string& desc) {
    record(date, amount, desc);
    acc.change(date, getDebt());
}

void CreditAccount::withdraw(const Date& date, double amount, const string& desc) {
    if (amount - getBalance() > credit) {
        error("not enough credit");
    } else {
        record(date, -amount, desc);
        acc.change(date, getDebt());
    }
}

void CreditAccount::settle(const Date& date) {
    double interest = acc.getSum(date) * rate;
    if (interest != 0) record(date, interest, "interest");
    if (date.getMonth() == 1)
        record(date, -fee, "annual fee");
    acc.reset(date, getDebt());
}

void CreditAccount::show() const {
    Account::show();
    cout << "\tAvailable credit:" << getAvailableCredit();
}

  

#include"account.h"
#include<iostream>

using namespace std;

int main() {
    Date date(2008, 11, 1);
    SavingsAccount sa1(date, "S3755217", 0.015);
    SavingsAccount sa2(date, "02342342", 0.015);
    CreditAccount ca(date, "C5392394", 10000, 0.0005, 50);

    sa1.deposit(Date(2008, 11, 5), 5000, "salary");
    ca.withdraw(Date(2008, 11, 15), 2000, "buy a cell");
    sa2.deposit(Date(2008, 11, 25), 10000, "sell stock 0323");

    ca.settle(Date(2008, 12, 1));

    ca.deposit(Date(2008, 12, 1), 2016, "repay the credit");
    sa1.deposit(Date(2008, 12, 5), 5500, "salary");

    sa1.settle(Date(2009, 1, 1));
    sa2.settle(Date(2009, 1, 1));
    ca.settle(Date(2009, 1, 1));

    cout << endl;
    sa1.show(); cout << endl;
    sa2.show(); cout << endl;
    ca.show(); cout << endl;
    cout << "Total:" << Account::getTotal() << endl;

    return 0;
}

  

 

 

   

 

标签:std,const,int,void,实验,date,include
From: https://www.cnblogs.com/0448wyz/p/18554917

相关文章

  • 20222416 2024-2025-1 《网络与系统攻防技术》实验六实验报告
    1.实验内容本次实验使用的MetasploitFramework(MSF)是一款开源安全漏洞检测工具,附带数千个已知的软件漏洞,并保持持续更新。Metasploit可以用来信息收集、漏洞探测、漏洞利用等渗透测试的全流程。(1)前期渗透①主机发现(可用Aux中的arp_sweep,search一下就可以use)②端口扫描:可以直......
  • 汇编语言-实验10编写子程序
    名称:show_str功能,在指定的位置,用指定的颜色,显示一个用0结束的字符串。参数:(dh)行号。(dl)列号,(cl)颜色ds:si指向字符串首地址返回无应用举例:8行3列,用绿色显示data中的字符串代码如下:assumecs:codedatasegmentdb'Welcometomasm!',0dataendscodesegmentstart:movdh,8......
  • 11.18实验18:迭代器模式
    [实验任务一]:JAVA和C++常见数据结构迭代器的使用信1305班共44名同学,每名同学都有姓名,学号和年龄等属性,分别使用JAVA内置迭代器和C++中标准模板库(STL)实现对同学信息的遍历,要求按照学号从小到大和从大到小两种次序输出学生信息。实验要求:1. 搜集并掌握JAVA和C++中常见的数据结构......
  • 11.19实验19:中介者模式
    [实验任务一]:虚拟聊天室在“虚拟聊天室”实例中增加一个新的具体聊天室类和一个新的具体会员类,要求如下:1.新的具体聊天室中发送的图片大小不得超过20M。2.新的具体聊天室中发送的文字长度不得超过100个字符。3.新的具体会员类可以发送图片信息和文本信息。4.新的具体会员......
  • 20222327 2024-2025-1 《网络与系统攻防技术》实验五实验报告
    一、实验内容网络攻击需要搜集的信息包括:攻击对象的名称和域名;目标网络位置,如IP地址、DNS服务器、外部网络拓扑结构;现实世界中的对应物,如注册信息、电话号段、网络或安全管理员及联系方式、地理位置等;网络地图,包括活跃主机IP、操作系统类型、开放的端口与运行的网络服务类型,以及......
  • 20222319 2024-2025-1 《网络与系统攻防技术》实验六实验报告
    1.实验内容1.1本周学习内容本周主要学习了利用msf实现对漏洞主机攻击的具体实现原理与过程,认识XP系统、win7系统存在的许多可利用漏洞,再次复习了namp的指令,学会了主机发现、系统扫描、漏洞扫描等技术。1.2实验要求(1)前期渗透主机发现端口扫描扫描系统版本,漏洞等(2)Vsf......
  • 20222405 2024-2025-1 《网络与系统攻防技术》实验五实验报告
    1.实验内容信息搜集是网络攻防的关键环节,通过分析目标系统获取有价值的信息,分为被动收集和主动扫描两种方式。被动收集利用GoogleHacking、WHOIS等工具从公开资源中提取域名、IP地址、子域等数据;主动扫描则借助nmap等工具识别目标的开放端口、服务及可能存在的漏洞。熟练掌......
  • 大数据实验问题
    出现的问题:hbase在配置过程中出现java路径配置错误问题:在HBase环境配置文件hbase-env.sh中,JAVA_HOME尚未配置解决方案(列出遇到的问题和解决办法,列出没有解决的问题):于hbase-env.sh中配置GNUnano2.9.3/home/hadoop/hbase/conf/hbase-env.sh#!/usr/bin/envbash#expor......
  • B/S实验(1)
    部分源码<!DOCTYPEHTML><html><head><metacharset="utf-8"><metaname="author"content="orderbydede58.com"/><metaname="renderer"content="webkit|ie-comp|ie-stand"......
  • 20222302 2024-2025-1 《网络与系统攻防技术》实验六实验报告
    1.实验内容掌握metasploit的用法。下载官方靶机Metasploitable2,完成下面实验内容。(1)前期渗透①主机发现(可用Aux中的arp_sweep,search一下就可以use)②端口扫描:可以直接用nmap,也可以用Aux中的portscan/tcp等。③选做:也可以扫系统版本、漏洞等。(2)Vsftpd源码包后门漏洞(21端口)(3)S......