C++ primer plus第十二章编程练习答案

1.对于下面的声明:

class Cow{
char name[20] ;
char + hobby;

double weight ;

public:
Cow();
Cow(const char * nm,const char * ho,double wt);

Cow(const Cow c&);

~Cow();
Cow  operator=(const Cow & c);

void ShowCow() const; // display all cow data

给这个类提供实现,并编写一个使用所有成员函数的小程序。

#include <iostream>
#include "cow.h"int main()
{using std::cout;using std::endl;Cow temp1;Cow temp2("MZZDX", "Programming", 30);Cow temp3(temp2);cout << "Here are some cows:" << endl;cout << "The first:" << endl;temp1.ShowCow();cout << "The second:" << endl;temp2.ShowCow();cout << "The third:" << endl;temp3.ShowCow();temp1 = temp3;cout << "After assignment for temp1:" << endl;temp1.ShowCow();return 0;
}
#ifndef COW_H_
#define COW_H_class Cow
{
private:char name[20];char *hobby;double weight;public:Cow();Cow(const char *nm, const char *ho, double wt);Cow(const Cow &c);~Cow();Cow &operator=(const Cow &c);void ShowCow() const;
};#endif
#include <iostream>
#include "cow.h"
#include <cstring>Cow::Cow()
{std::strcpy(name, "\0");hobby = new char[1];hobby[0] = '\0';weight = 0.0;
}Cow::Cow(const char *nm, const char *ho, double wt)
{std::strncpy(name, nm, 20);name[19] = '\0';hobby = new char[strlen(ho) + 1];std::strcpy(hobby, ho);weight = wt;
}Cow::Cow(const Cow &c)
{std::strcpy(name, c.name);hobby = new char[strlen(c.hobby) + 1];std::strcpy(hobby, c.hobby);weight = c.weight;
}Cow::~Cow()
{delete[] hobby;
}Cow &Cow::operator=(const Cow &c)
{if (this != &c){delete[] hobby;std::strcpy(name, c.name);hobby = new char[strlen(c.hobby) + 1];std::strcpy(hobby, c.hobby);weight = c.weight;}return *this;
}void Cow::ShowCow() const
{std::cout << "Cow name: " << name << std::endl;std::cout << "Cow hobby: " << hobby << std::endl;std::cout << "Cow weight: " << weight << "\n\n";
}

2.通过完成下面的工作来改进String 类声明(即将 Stringl.h升级为 String2.h)。
a.对+运算符进行重载,使之可将两个学符串合并成1个。
b.提供一个Stringlow()成员函数,将字符审中所有的字母字符转换为小写(别忘了cctype 系列字符函数)

c.提供String()成员函数,将字符串中所有字母字符转换成大写。
d,提供一个这样的成员函数,它接受一个 char 参数,返回该字符在字符串中出现的次数使用下面的程序来测试您的工作:

// pe122.cPP
#include <iostream>
using namespace std;
#include "string2.h"
int main(]
String sl("and I am a C++ student.");
String s2 -"please enter your name: ";
String s3;
// overloaded << operator
cout ec s2:
cin >> s3;// overloaded >> operators2="My name is"+s3;// overloaded =,+ operatorscout << B2 <<, n";
g2-g2+81:
s2,stringup();// converts string to uppercasecout c<"The string\n"cc s2 cc"ncontaing" <c s2.has('A')<< m IA'characterg in it.\n";
sl = "red";// String(const char ).// then String & operatora(const String5)string rgb[3] =String(sl],String("green"),String("blue"));cout <<"Entcr the name of a primary color for mixing light:";String ans;
bool success = false;
while (cin >> ans]
ans.stringlow():/ converts string to lowercasefor (inti=0;i<3;i++)if (ans == rqb[i]) // overloaded == operatorcout c< "That's right!\n";success = true;break:
if (success)
break;
else

cout ce "Try again!\n";
cout <<"Bye\n";return 0;

输出应与下面相似:
Please enter your name: Fretta Farbo
My name is Pretta Farbo.
The string
MY NAME IS FRETTA FARBO AND I AM A C++ STUDENTcontains 6"A' characters in it.
Enter the name of a primary color for mixing light: yellowTry again!
blUE
That'sright!
Bye

#include <iostream>
using namespace std;
#include "string2.h"int main()
{String s1(" and I am a C++ student.");String s2 = "Please enter your name: ";String s3;cout << s2;cin >> s3;s2 = "My name is " + s3;cout << s2 << ".\n";s2 = s2 + s1;s2.stringup();cout << "The string \n";cout << s2 << "\ncontains " << s2.has('A');cout << " 'A' characters in it.\n";s1 = "red";String rgb[3] = {String(s1), String("green"), String("blue")};cout << "Enter the name of a primary color for mixing light: ";String ans;bool success = false;while (cin >> ans){ans.stringlow();for (int i = 0; i < 3; i++){if (ans == rgb[i]){cout << "That's right!\n";success = true;break;}}if (success){break;}else{cout << "Try again!\n";}}cout << "Bye\n";return 0;
}
#ifndef STRING2_H_
#define STRING2_H_
#include <iostream>
using std::istream;
using std::ostream;class String
{
private:char *str;                    //字符串首字符指针;int len;                      //记录字符串长度;static int num_strings;       //记录构造的字符串数目;static const int CINLIM = 80; //限制输入字符个数;public:String(const char *s);String();String(const String &st);~String();int length() const { return len; }String &operator=(const String &st);String &operator=(const char *s);String operator+(const char *s);char &operator[](int i);const char &operator[](int i) const;friend bool operator<(const String &st1, const String &st2);friend bool operator>(const String &st1, const String &st2);friend bool operator==(const String &st1, const String &st2);friend ostream &operator<<(ostream &os, const String &st);friend istream &operator>>(istream &is, String &st);friend String operator+(const char *s, const String &st);friend String operator+(const String &st1, const String &st2);void stringlow();void stringup();unsigned has(const char s) const;static int HowMany();
};#endif
#include <cctype>
#include <cstring>
#include "string2.h"
using std::cin;
using std::cout;int String::num_strings = 0;int String::HowMany()
{return num_strings;
}String::String(const char *s)
{len = std::strlen(s);str = new char[len + 1];std::strcpy(str, s);num_strings++;
}String::String()
{len = 4;str = new char[1];str[0] = '\0';num_strings++;
}String::String(const String &st)
{num_strings++;len = st.len;str = new char[len + 1];std::strcpy(str, st.str);
}String::~String()
{--num_strings;delete[] str;
}String &String::operator=(const String &st)
{if (this == &st){return *this;}delete[] str;len = st.len;str = new char[len + 1];std::strcpy(str, st.str);return *this;
}String &String::operator=(const char *s)
{delete[] str;len = std::strlen(s);str = new char[len + 1];std::strcpy(str, s);return *this;
}String String::operator+(const char *s)
{int length = strlen(s) + len;char *temp = new char[length + 1];strcpy(temp, str);strcat(temp, s);String new_str(temp);delete[] temp;return new_str;
}char &String::operator[](int i)
{return str[i];
}const char &String::operator[](int i) const
{return str[i];
}bool operator<(const String &st1, const String &st2)
{return (std::strcmp(st1.str, st2.str) < 0);
}bool operator>(const String &st1, const String &st2)
{return st2 < st1;
}bool operator==(const String &st1, const String &st2)
{return (std::strcmp(st1.str, st2.str) == 0);
}ostream &operator<<(ostream &os, const String &st)
{os << st.str;return os;
}istream &operator>>(istream &is, String &st)
{char temp[String::CINLIM];is.get(temp, String::CINLIM);if (is){st = temp;}while (is && is.get() != '\n')continue;return is;
}String operator+(const char *s, const String &st)
{int length = strlen(s) + st.len;char *temp = new char[length + 1];strcpy(temp, s);strcat(temp, st.str);String new_str(temp);delete[] temp;return new_str;
}String operator+(const String &st1, const String &st2)
{int length = st1.len + st2.len;char *temp = new char[length + 1];strcpy(temp, st1.str);strcat(temp, st2.str);String new_str(temp);delete[] temp;return new_str;
}void String::stringlow()
{for (int i = 0; i < len; i++){str[i] = tolower(str[i]);}
}void String::stringup()
{for (int i = 0; i < len; i++){str[i] = toupper(str[i]);}
}unsigned String::has(const char s) const
{unsigned count = 0;for (int i = 0; i < len; i++){count += (s == str[i]);}return count;
}


3.新编写程序清单 10.7 和程序清单 10.8 描述的 Stok 类,使之使用动分配的内存,而不是 string类对象来存储股票名称。另外,使用重载的 operator<<0定义代替show(成员函数。再使用程序清单 10.9测试新的定义程序。

#include <iostream>
#include "stock20.h"const int STKS = 4;int main()
{Stock stocks[STKS] = {Stock("NanoSmart", 12, 20.0),Stock("Boffo Objects", 200, 2.0),Stock("Monolithic Obelisks", 130, 3.25),Stock("Fleep Enterprises", 60, 6.5)};std::cout << "Stock holdings:\n";for (int st = 0; st < STKS; st++){std::cout << stocks[st] << std::endl;}const Stock *top = &stocks[0];for (int st = 1; st < STKS; st++){top = &top->topval(stocks[st]);}std::cout << "\nMost valuable holding:\n";std::cout << *top;return 0;
}
#ifndef STOCK20_H_
#define STOCK20_H_
#include <iostream>class Stock
{
private:char *company;int shares;double share_val;double total_val;void set_tot() { total_val = shares * share_val; }public:Stock();Stock(const char *s, long n = 0, double pr = 0.0);~Stock();void buy(long num, double price);void sell(long num, double price);void update(double price);friend std::ostream &operator<<(std::ostream &os, const Stock &st);const Stock &topval(const Stock &s) const;
};#endif
#include <iostream>
#include "stock20.h"
using namespace std;
#include <cstring>Stock::Stock()
{company = new char[1];company[0] = '\0';shares = 0;share_val = 0.0;total_val = 0.0;
}Stock::Stock(const char *s, long n, double pr)
{company = new char[strlen(s) + 1];std::strcpy(company, s);if (n < 0){std::cout << "Number of shares can't be negative; ";std::cout << company << " shares set to 0.\n";shares = 0;}else{shares = n;}share_val = pr;set_tot();
}Stock::~Stock()
{delete[] company;
}void Stock::buy(long num, double price)
{if (num < 0){std::cout << "Number of shares purchased can't be negative. ";std::cout << "Transaction is aborted.\n";}else{shares += num;share_val = price;set_tot();}
}void Stock::sell(long num, double price)
{using std::cout;if (num < 0){cout << "Number of shares sold can't be negative. ";cout << "Transaction is aborted.\n";}else if (num > shares){cout << "You can't sell more than you have! ";cout << "Transaction is aborted.\n";}else{shares -= num;share_val = price;set_tot();}
}void Stock::update(double price)
{share_val = price;set_tot();
}std::ostream &operator<<(std::ostream &os, const Stock &st)
{os << "Company: " << st.company << std::endl;os << "Shares: " << st.shares << std::endl;os << "Share Price: " << st.share_val << std::endl;os << "Total Worth: " << st.total_val << std::endl;return os;
}const Stock &Stock::topval(const Stock &s) const
{return s.total_val > total_val ? s : *this;
}

4.请看下面程序清单10.10 定义的 Stack 类的变量:

// stack.h -- class declaration for the stack ADTtypedef unsigned long Item;
class Stack
private:
enum(MAX-10;Item* pitems;int size;
int topi
// constant epecific to clasc
// holds stack items
// number of elements in stack
// index for top stack item
public:
Stack(int n = MAX):// creates stack with n elementsStack(const Stack & st);-Stack();
bool isempty) const;
bool isfull() const;
// push() returns false if stack already is full,true otherwisebool push(const Item & item); // add item to stack// pop() returns false if stack already is empty, true otherwisebool pop(Item &item): // pop top into itemStack & operator=(const Stack  st];

正如私有成员表明的,这个类使用动态分配的数组来保存栈项。请重新编写方法,以适应这种新的表示法,并编写一个程序来演示所有的方法,包括复制构造函数和赋值运算符。

#include <iostream>
#include "stack.h"int main()
{using namespace std;Stack st;Item temp = 1000UL;st.push(temp);temp = 2000UL;st.push(temp);temp = 3000UL;st.push(temp);Stack st1(st);Stack st2;st2 = st1;cout << "Here are some stack contents:" << endl;cout << "Stack st:" << endl;cout << st;cout << "Stack st1:" << endl;cout << st1;cout << "Stack st2:" << endl;cout << st2;cout << "Bye\n";return 0;
}
#ifndef STACK_H_
#define STACK_H_
#include <iostream>typedef unsigned long Item;class Stack
{
private:enum {MAX = 10};Item *pitems;int size;int top;public:Stack(int n = MAX);Stack(const Stack &st);~Stack();bool isempty() const;bool isfull() const;bool push(const Item &item);bool pop(Item &item);Stack &operator=(const Stack &st);friend std::ostream &operator<<(std::ostream &os, const Stack &st);
};#endif
#include "stack.h"Stack::Stack(int n)
{top = 0;if (n > MAX) //长度大于MAX时的情况;{std::cout << "The length of stack can't exceed 10.\n";std::cout << "So initialize the length to 10.\n";size = MAX;}else if (n < 0) //长度小于0的情况;{std::cout << "The length of stack can't less than 0.\n";std::cout << "So initialize the length to 10.\n";size = MAX;}else{size = n;}pitems = new Item[size];
}Stack::Stack(const Stack &st)
{size = st.size, top = st.top;pitems = new Item[size];for (int i = 0; i < top; i++){pitems[i] = st.pitems[i];}
}Stack::~Stack()
{delete[] pitems;
}bool Stack::isempty() const
{return top == 0;
}bool Stack::isfull() const
{return top == n;
}bool Stack::push(const Item &item)
{if (top < MAX){pitems[top++] = item;return true;}else{return false;}
}bool Stack::pop(Item &item)
{if (top > 0){item = pitems[--top];return true;}else{return false;}
}Stack &Stack::operator=(const Stack &st)
{if (this == &st){return *this;}delete[] pitems;size = st.size;top = st.top;pitems = new Item[size];for (int i = 0; i < top; i++){pitems[i] = st.pitems[i];}return *this;
}std::ostream &operator<<(std::ostream &os, const Stack &st)
{for (int i = st.top - 1; i >= 0; i--){os << st.pitems[i] << std::endl;}return os;
}

5.Heather 银行进行的研究表明,ATM 客户不希望排队时间不超过1分钟使用程序清单1210中的模拟,找出要使平均等候时间为1分钟,每小时到达的客户数应为多少(试验时间不短于 100 小时)?

18

6.Heather 银行想知道,如果再开设一台 ATM,情况将如何。请对模拟进行修改,以包含两个队列。假设当第一台ATM 前的排队人数少于第二台ATM 时,客户将排在第一队,否则将排在第二队。然后再找出要使平均等候时间为1分钟,每小时到达的客户数应该为多少(注意,这是一个非线性问题,即将ATM数量加倍,并不能保证每小时处理的客户数量也翻倍,并确保客户等候的时间少于1 分钟)?

#include <iostream>
#include <cstdlib>
#include <ctime>
#include "queue.h"
using namespace std;
const int MIN_PER_HR = 60;bool newcustomer(double x);int main()
{srand(time(0));cout << "Case Study: Bank of Heather Automatic Teller\n";cout << "Enter maximum size of queue: ";int qs;cin >> qs;Queue line1(qs); //构造第一台ATM机;Queue line2(qs); //构造第二台ATM机;cout << "Enter the number of simulation hours: ";int hours;cin >> hours;long cyclelimit = MIN_PER_HR * hours;cout << "Enter the average number of customers per hour: ";double perhour;cin >> perhour;double min_per_cust;min_per_cust = MIN_PER_HR / perhour;long turnaways = 0;long customers = 0;long served = 0;long sum_line = 0;int wait_time1 = 0; //第一台ATM机的等待时间;int wait_time2 = 0; //第二台ATM机的等待时间;long line_wait = 0;for (int cycle = 0; cycle < cyclelimit; cycle++){Item temp;if (newcustomer(min_per_cust)){if (line1.isfull() && line2.isfull())turnaways++;else{customers++;temp.set(cycle);if (line1.queuecount() <= line2.queuecount()) //第一台ATM机人数小于第二台;{line1.enqueue(temp); //顾客排在第一队;}else{line2.enqueue(temp); //否则排在第二队;}}}if (wait_time1 <= 0 && !line1.isempty()){line1.dequeue(temp);wait_time1 = temp.ptime();line_wait += cycle - temp.when();served++;}if (wait_time1 > 0){wait_time1--;}sum_line += line1.queuecount();if (wait_time2 <= 0 && !line2.isempty()){line2.dequeue(temp);wait_time2 = temp.ptime();line_wait += cycle - temp.when();served++;}if (wait_time2 > 0){wait_time2--;}sum_line += line2.queuecount();}if (customers > 0){cout << "customers accepted: " << customers << endl;cout << "  customers served: " << served << endl;cout << "         turnaways: " << turnaways << endl;cout << "average queue size: ";cout.precision(2);cout.setf(ios_base::fixed, ios_base::floatfield);cout << (double)sum_line / cyclelimit << endl;cout << " average wait time: ";cout << (double)line_wait / served << " minutes\n";}else{cout << "No customers!\n";}cout << "Done!\n";return 0;
}bool newcustomer(double x)
{return (std::rand() * x / RAND_MAX < 1);
}
#ifndef QUEUE_H_
#define QUEUE_H_class Customer
{
private:long arrive;int processtime;public:Customer() : arrive(0L), processtime(0) {}void set(long when);long when() const { return arrive; }int ptime() const { return processtime; }
};typedef Customer Item;class Queue
{
private:struct Node{ Item item; struct Node *next; };enum { Q_SIZE = 10 };Node *front;Node *rear;int items;const int qsize;Queue(const Queue &q) : qsize(0) {}Queue &operator=(const Queue &q) { return *this; }public:Queue(int qs = Q_SIZE);~Queue();bool isempty() const;bool isfull() const;int queuecount() const;bool enqueue(const Item &item);bool dequeue(Item &item);
};#endif
#include "queue.h"
#include <cstdlib>Queue::Queue(int qs) : qsize(qs)
{front = rear = NULL;items = 0;
}Queue::~Queue()
{Node *temp;while (front != NULL){temp = front;front = front->next;delete temp;}
}bool Queue::isempty() const
{return items == 0;
}bool Queue::isfull() const
{return items == qsize;
}int Queue::queuecount() const
{return items;
}bool Queue::enqueue(const Item &item)
{if (isfull()){return false;}Node *add = new Node;add->item = item;add->next = NULL;items++;if (front == NULL){front = add;}else{rear->next = add;}rear = add;return true;
}bool Queue::dequeue(Item &item)
{if (front == NULL){return false;}item = front->item;items--;Node *temp = front;front = front->next;delete temp;if (items == 0){rear = NULL;}return true;
}void Customer::set(long when)
{processtime = std::rand() % 3 + 1;arrive = when;
}

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mzph.cn/news/71834.shtml

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

02-zookeeper分布式锁案例

1 Zookeeper分布式案例 1.1 Zookeeper分布式锁原理 核心思想&#xff1a;当客户端要获取锁&#xff0c;则创建节点&#xff0c;使用完锁&#xff0c;则删除该节点。 当我们假设根节点/ 下有/locks节点时 1&#xff09;客户端获取锁时&#xff0c;在locks节点下创建临时顺序…

go小知识2

Golang开发新手常犯的50个错误_gezhonglei2007的博客-CSDN博客 一些题目整理&#xff0c;附带大佬的解释 1.go中哪些值不能寻址& 常量&#xff08;const常量&#xff0c;字面值3.14&#xff0c;字符串“xxx”&#xff0c;函数或方法, map的val值&#xff09; golang中接…

Python、Rust中的协程

协程 协程在不同的堆栈上同时运行&#xff0c;但每次只有一个协程运行&#xff0c;而其调用者则等待: F启动G&#xff0c;但G并不会立即运行&#xff0c;F必须显式的恢复G&#xff0c;然后 G 开始运行。在任何时候&#xff0c;G 都可能转身并让步返回到 F。这会暂停 G 并继续…

OpenCV(二十五):边缘检测(一)

目录 1.边缘检测原理 2.Sobel算子边缘检测 3.Scharr算子边缘检测 4.两种算子的生成getDerivKernels() 1.边缘检测原理 其原理是基于图像中灰度值的变化来捕捉图像中的边界和轮廓。梯度则表示了图像中像素强度变化的强弱和方向。 所以沿梯度方向找到有最大梯度值的像素&…

Linux网络编程 网络基础知识

目录 1.网络的历史和协议的分成 2.网络互联促成了TCP/IP协议的产生 3.网络的体系结构 4.TCP/IP协议族体系 5.网络各层的协议解释 6.网络的封包和拆包 7.网络预备知识 1.网络的历史和协议的分成 Internet-"冷战"的产物 1957年十月和十一月&#xff0c;前苏…

C#__线程的优先级和状态控制

线程的优先级&#xff1a; 一个CPU同一时刻只能做一件事情&#xff0c;哪个线程优先级高哪个先运行&#xff0c;优先级相同看调度算法。 在Thread类中的Priority属性&#xff08;Highest,Above,Normal,BelowNormal,Lowest&#xff09;可以影响线程的优先级 关于…

swiper删除虚拟slide问题

在存在缓存的情况下&#xff0c;删除较前的slide&#xff0c;会出现当前slide与后一个slide重复出现的情况 假设当前存在5个slide&#xff0c;且这5个slide已缓存&#xff0c;则删除slide2后&#xff0c;仍为5个slide&#xff0c;且slide2的内容变为slide3的内容&#xff0c;此…

Pushgetway安装和使用

1、Pushgetway安装和使用 1.1 Pushgateway是什么 pushgateway 是另一种数据采集的方式&#xff0c;采用被动推送来获取监控数据的prometheus插件&#xff0c;它可以单独运行在 任何节点上&#xff0c;并不一定要运行在被监控的客户端。 首先通过用户自定义编写的脚本把需要监…

记一次时间序列算法的自回归预测--ARAutoreg

背景 最近公司给客户要做一些数据的预测&#xff0c;但是客户不清楚哪些做起来比较符合他们的&#xff0c;于是在经过与业务方的沟通&#xff0c;瞄准了两个方面的数据 1.工程数据&#xff1a;对工程数据做评估&#xff0c;然后做预警&#xff0c;这个想法是好的&#xff0c;…

物流供应商实现供应链自动化的3种方法

当前影响供应链的全球性问题(如新冠肺炎疫情)正在推动许多物流供应商重新评估和简化其流程。运输协调中的摩擦只会加剧供应商无法控制的现有延误和风险。值得庆幸的是&#xff0c;供应链专业人员可以通过端到端的供应链自动化消除延迟&#xff0c;简化与合作伙伴的沟通&#xf…

DGIOT-Modbus-RTU控制指令05、06的配置与下发

[小 迪 导 读]&#xff1a;伴随工业物联网在实际应用中普及&#xff0c;Modbus-RTU作为行业内的标准化通讯协议。在为物联网起到采集作用的同时&#xff0c;设备的控制也是一个密不可分的环节。 场景解析&#xff1a;在使用Modbus对设备进行采集后&#xff0c;可以通过自动控制…

Python 正则表达式:强大的文本处理工具

概念&#xff1a; 正则表达式是一种强大的文本匹配和处理工具&#xff0c;它可以用来在字符串中查找、替换和提取符合某种规则的内容。在Python中&#xff0c;使用re模块可以轻松地操作正则表达式&#xff0c;它提供了丰富的功能和灵活的语法。 场景&#xff1a; 正则表达式…

多波束测线问题

多波束测线问题 问题的背景是海洋测深技术&#xff0c;特别是涉及单波束测深和多波束测深系统。这些系统利用声波传播原理来测量水体深度。 单波束测深系统通过向海底发射声波信号并记录其返回时间来测量水深。该系统的特点是每次只有一个波束打到海底&#xff0c;因此数据分布…

理解项目开发(寺庙小程序)

转载自&#xff1a;历经一年&#xff0c;开发一个寺庙小程序&#xff01; (qq.com) 破防了&#xff01;为方丈开发一款纪念小程序&#xff01; (qq.com) 下面内容转载自&#xff1a;程序员5K为青岛啤酒节开发个点餐系统&#xff01; (qq.com) 看一个人如何完成一个项目的开发…

CSS笔记(黑马程序员pink老师前端)浮动,清除浮动

浮动可以改变标签的默认排列方式。浮动元素常与标准流的父元素搭配使用. 网页布局第一准则:多个块级元素纵向排列找标准流&#xff0c;多个块级元素横向排列找浮动。 float属性用于创建浮动框&#xff0c;将其移动到一边&#xff0c;直到左边缘或右边缘触及包含块或另一个浮动框…

分类预测 | MATLAB实现PCA-LSTM(主成分长短期记忆神经网络)分类预测

分类预测 | MATLAB实现PCA-LSTM(主成分长短期记忆神经网络)分类预测 目录 分类预测 | MATLAB实现PCA-LSTM(主成分长短期记忆神经网络)分类预测预测效果基本介绍程序设计参考资料致谢 预测效果 基本介绍 MATLAB实现PCA-LSTM(主成分长短期记忆神经网络)分类预测。Matlab实现基于P…

Python基础List列表定义与函数

如何定义一个非空的列表&#xff1f; name_list ["liming","xiaohong",15,{"hobby":"basketball"}] 列表的特点&#xff1a; 1.列表是有序的 2.可以存放多个元素 3.每个元素可以是任何数据类型 定义一个空列表 name_list [] 访…

【java】【项目实战】[外卖十一]项目优化(Ngnix)

目录 一、Nginx概述 1、Nginx介绍 2、Nginx下载和安装 3、Nginx目录结构 二、Nginx命令 1、查看版本 2、检查配置文件正确性 3、启动和停止 4、重新加载配置文件 三、Nginx配置文件结构 1、全局块 2、events块 3、http块 四、Nginx具体应用 1、部署静态资源 2、…

LeetCode 904. 水果成篮

题目链接 力扣&#xff08;LeetCode&#xff09;官网 - 全球极客挚爱的技术成长平台 题目解析 在你去摘水果的时候&#xff0c;你当前只能拥有两种种类的水果&#xff0c;若想拿第三种水果&#xff0c;就需要发下前两种水果中的一种。 法一&#xff1a;滑动窗口哈希表(未优化…

【Linux】shell脚本和bat脚本:

文章目录 一、脚本对应环境&#xff1a;【1】shell&#xff1a;linux环境&#xff1b;后缀名为.sh【2】bat&#xff1a;windows环境&#xff1b;后缀名为.bat或者.cmd 二、脚本执行&#xff1a;【1】shell执行【2】bat脚本执行 三、脚本相关命令&#xff1a;1. shell命令【1】s…