2025.6.1学习笔记
2025.6.1学习笔记
为什么我为OI泪目,因为我菜的离谱。。。
每天记网页笔记!
Linux命令
VitualBox >> Noi.Linux.2.0
打开虚拟机
ls 目录内容
ls -l 所有信息
ls -lh plus -l
ls -a 隐藏文件
cd _file 进入_file文件夹(Terminal)
pwd 文件路径
mkdir _file1 _file2 _file3创建文件
mkdir -p _filebox/data/1/2/3/4/5/6/7/8/9 递归创建
rm file.cpp 删除(慎用)
rm -r file.cpp 递归删除(极度危!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!)
touch file1.cpp file2.cpp 创建文件
cp a.cpp b.cpp copy
cp a.cpp b_box copy到文件夹
mv a.cpp b.cpp 移动=重名名
vim a.cpp 大佬使用,我们只能装一下X
g++ -std=c++14 -O2 -Wall a.cpp -o a按照c++14编译,开启-O2优化,带Wall报警(常用)
g++ -std=c++14 -O2 -Wall "-Wl,--stack=536870912" a.cpp -o a按照c++14编译,开启-O2优化,带Wall报警,栈开到512MB防爆栈(Windows可用,Linux未检验)
time ./a 竞赛时间=user+sys (Linux系统,Windows不可用)
class
// 精注释版class入门参考代码
#include<bits/stdc++.h>
using namespace std;
class Point
{
private:
double x;//x变量为私有,外部代码不可访问
double y;//y变量为私有,外部代码不可访问
void fPointout()//fPointout()函数为私有,外部代码不可访问
{
printf("FPointout()>>The Point is(%lf,%lf)\n",x,y);
}
public:
Point():x(0.0),y(0.0)// 构造函数 (无参)
{
printf("Point()>>You had built a Point=(0.0,0.0)\n");
}
Point(double x_val,double y_val):x(x_val),y(y_val)// 构造函数 (带参)
{
printf("Point()>>You had built a Point=(%lf,%lf)\n",x_val,y_val);
}
// 成员函数:获取x坐标
// 成员函数调用形式:Point p; p.getX()
// 以下皆同理
double getX() const//加入const后里面的值不可以修改
{
// x=x+1; //加入const后里面的值不可以修改
return x;
}
// 成员函数:获取y坐标
double getY() const
{
return y;
}
void set(double x_val,double y_val)
{
x=x_val,y=y_val;
}
double dis_to_O()
{
return sqrt(x*x+y*y);
}
void Pointout()
{
printf("Pointout()>>The Point is(%lf,%lf)\n",x,y);
}
~Point()//析构函数,=在删除时自动调用的函数
{
printf("~Point()>>The Point (%lf,%lf) has taken off\n",x,y);
}
};
int main()
{
Point p1; // 调用默认构造函数,p1是(0,0)
Point p2(3.0, 4.0); // 调用带参构造函数,p2是(3,4)
p2.Pointout();
// p2.x; //x变量为私有,不可访问
// p2.fPointout(); //fPointout()函数为私有,不可访问
p1.set(1.0, 1.0);
printf("P1 after set:(%lf,%lf)\n",p1.getX(),p2.getY());
printf("Distance P2 to O_Point:%lf\n",p2.dis_to_O());
return 0; // p1和p2在此处销毁,自动调用析构函数
}
输出
Point()>>You had built a Point=(0.0,0.0)
Point()>>You had built a Point=(3.000000,4.000000)
Pointout()>>The Point is(3.000000,4.000000)
P1 after set:(1.000000,4.000000)
Distance P2 to O_Point:5.000000
~Point()>>The Point (3.000000,4.000000) has taken off
~Point()>>The Point (1.000000,1.000000) has taken off
bitset及重要函数
bitset应用见2025.6.1讲课文件

浙公网安备 33010602011771号