T1 LC5384 拥有最多糖果的孩子
直接遍历操作即可
T2 LC5385 改变一个整数能得到的最大差值
很好的一道题目
- 最大:最前面的一位变成9
最小:
- 首位大于1,直接首位变成1
- 首位等于1,后面非零非1的位变成0
T3 LC5386 检查一个字符串是否可以打破另一个字符串
排序,就变成常规题目了
今日学习总结
首先完成了学校的OJ
vector & deque
常用:
#vectorpush_back();pop_back();
#dequepush_back();push_front();pop_back();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 的包❌目前提示依赖错误
可以通过修改源来解决,一下是最新版本的清华源
deb http://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal main restricteddeb http://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal-updates main restricteddeb http://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal universedeb http://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal-updates universedeb http://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal multiversedeb http://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal-updates multiversedeb http://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal-backports main restricted universe multiversedeb http://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal-security main restricteddeb http://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal-security universedeb http://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal-security multiverse
sudo apt updatesudo apt upgrade
重新安装的时候就可以正常安装了
sudo apt install build-essential
G++ 安装成功
$ g++ --versiong++ (Ubuntu 9.3.0-10ubuntu2) 9.3.0Copyright (C) 2019 Free Software Foundation, Inc.This is free software; see the source for copying conditions. There is NOwarranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
G++ 编译
$ g++ -o hello hello.cc$ ./helloHello, World!
头文件编译
头文件
头文件里面使用:
#ifndef HEAD_H#define HAED_Hcode of head#endif
.cpp 文件
这个里面需要我们使用
#include "head.h"
全局变量
//头文件中extern int a;//main.cppint a;
运行编译出来的 .out 文件
./a.out
C++输出补零
使用标准的 cout.fill('0') 和 cout。width(2)
cout.fill('0');cout.width(2); cout << this->h << ':';cout.width(2); cout << this->m << ':';cout.width(2); cout << this->s << endl;
