四舍五入
12345678910#include <bits/stdc++.h>using namespace std;int main() { double d; d = 0.325; // 其中的数字就是保留的位数 cout << fixed << setprecision(2) << d; return 0;}
冒泡排序
123456789101112131415161718192021222324#include <bits/stdc++.h>#define SIZE(arr) int(sizeof(arr) / sizeof(arr[0]))using namespace std;int main() { int a[] = {3, 5, 6, 4, 6, 3, 8}; int t; for (int i = 0; i < SIZE(a); i++) { for (int j = 0; j < SIZE(a) - 1; j++) { if (a[j] > a[j + 1]) { t = a[j]; a[j] = a[j + 1]; a[j + 1] = t; } } } for (int i = 0; i < SIZE(a); i++) { cout << a[i] << " "; ...
字符数组与字符串
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960#include <bits/stdc++.h>using namespace std;int main() { //字符数组 /* strlen(s1);求字符串长度 strcmp(s1, s2);字符串比较:按照字典排序比较大小 若s1的字典码大于s2返回正数反之返回负数,相等返回零 strncmp(s1, s2, n);把 s1,s2 的前 n 个进行比较 strcat(s1, s2);将 s2 连接到 s1 的后面 s1要有足够的空间存放 strncat(s1, s2, n);将 s2 的前 n 个字符连接到 s1 的后面 strcpy(s1, s2);将 s2 的内容拷贝给 s1,替换 s1 的内容 getline(cin, a); = gets(a); 行输入 cout << a << endl;可直接输出 ...
最值
12345678910111213141516171819#include <bits/stdc++.h>using namespace std;int main() { int a[4] = {3, 22, 3, 24}; int max, min = a[0]; for (int i = 0; i < 4; i++) { if (max < a[i]) { max = a[i]; } if (min > a[i]) { min = a[i]; } } cout << max << endl << min; return 0;}
Neofetch的可替代品给fastfetch
简介由于neofetch的停止更新,我们不得不寻找一些替代品比如 FastFetch 是neofetch的一个分支
下载1brew install fastfetch
Gostty
简介美观快速开箱即用的终端模拟器
下载1234export VER="1.1.3" && export ARCH="x86_64"wget https://github.com/psadi/ghostty-appimage/releases/download/v${VER}/Ghostty-${VERSION}-${ARCH}.AppImagechmod +x Ghostty-${VER}-${ARCH}.AppImagesudo install ./Ghostty-${VER}-${ARCH}.AppImage /usr/local/bin/ghostty
随后自行添加桌面环境
配置~/.config/ghostty/config
123maximize = truefont-size = 20font-family = MapleMono-NF-CN
Homebrew
简介一款Like-Unix的通用包管理器
下载12345/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"echo >> ~/.zshrcecho 'eval "$(/home/linuxbrew/.linuxbrew/bin/brew shellenv)"' >> ~/.zshrcsudo apt-get install build-essentialeval "$(/home/linuxbrew/.linuxbrew/bin/brew shellenv)"
yazi
简介一款开箱即用 扩展性强的终端文件管理器
安装请在此之前安装Nerd Font
1brew install yazi ffmpeg sevenzip jq poppler fd ripgrep fzf zoxide imagemagick
插件和配置将此代码放到您的zshrc/bashrc中
12345678function y() { local tmp="$(mktemp -t "yazi-cwd.XXXXXX")" cwd yazi "$@" --cwd-file="$tmp" if cwd="$(command cat -- "$tmp")" && [ -n "$cwd" ] && [ "$cwd" != "$PWD" ]; then builtin cd -- "$cwd" fi rm -f -- "$tmp&q ...
fzf
简介一款模糊文件查找器参考
下载1brew install fzf
配置在.zshrc中添加export FZF_COMPLETION_TRIGGER='\'
使用按下\+Tab来启动或fzf