T1 LC5384 拥有最多糖果的孩子

直接遍历操作即可

T2 LC5385 改变一个整数能得到的最大差值

很好的一道题目

  • 最大:最前面的一位变成9
  • 最小:

    • 首位大于1,直接首位变成1
    • 首位等于1,后面非零非1的位变成0

T3 LC5386 检查一个字符串是否可以打破另一个字符串

排序,就变成常规题目了

今日学习总结

首先完成了学校的OJ

vector & deque

常用:

  1. #vector
  2. push_back();
  3. pop_back();
  1. #deque
  2. push_back();
  3. push_front();
  4. pop_back();
  5. pop_front();

WSL

今天重新装上了 WSL —— Ubuntu 20.04 LTS

配置挂载 + 切换源

探究了GCC和G的区别:一般来说可以把 gcc 当成是 C 语言的编译器,g 是 C++ 的编译器。

G++ 在 WSL 上面编译

https://linuxconfig.org/how-to-install-g-the-c-compiler-on-ubuntu-20-04-lts-focal-fossa-linux

安装 G++ 的过程:

Ubuntu里面提供了一个 build-essential 的包❌目前提示依赖错误

可以通过修改源来解决,一下是最新版本的清华源

  1. deb http://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal main restricted
  2. deb http://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal-updates main restricted
  3. deb http://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal universe
  4. deb http://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal-updates universe
  5. deb http://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal multiverse
  6. deb http://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal-updates multiverse
  7. deb http://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal-backports main restricted universe multiverse
  8. deb http://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal-security main restricted
  9. deb http://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal-security universe
  10. deb http://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal-security multiverse
  1. sudo apt update
  2. sudo apt upgrade

重新安装的时候就可以正常安装了

  1. sudo apt install build-essential

G++ 安装成功

  1. $ g++ --version
  2. g++ (Ubuntu 9.3.0-10ubuntu2) 9.3.0
  3. Copyright (C) 2019 Free Software Foundation, Inc.
  4. This is free software; see the source for copying conditions. There is NO
  5. warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

G++ 编译

  1. $ g++ -o hello hello.cc
  2. $ ./hello
  3. Hello, World!

头文件编译

头文件

头文件里面使用:

  1. #ifndef HEAD_H
  2. #define HAED_H
  3. code of head
  4. #endif

.cpp 文件

这个里面需要我们使用

  1. #include "head.h"

全局变量

  1. //头文件中
  2. extern int a;
  3. //main.cpp
  4. int a;

运行编译出来的 .out 文件

  1. ./a.out

C++输出补零

使用标准的 cout.fill('0')cout。width(2)

  1. cout.fill('0');
  2. cout.width(2); cout << this->h << ':';
  3. cout.width(2); cout << this->m << ':';
  4. cout.width(2); cout << this->s << endl;

论文颜值分析

微调