编译命令
(NOI)Linux
- 在
~/.bashrc 末尾添加:
Bashcpl () {
g++ "./$1.cpp" -o "./$1" -O2 -std=c++14 -static -Wall -Wextra && echo "Compiled ./$1.cpp"
}
run () {
cpl "$1" && echo -e "Running ./$1\n" && time "./$1"
}
zp() {
zip -r "./$1.zip" "./$1" && echo "Compressed folder ./$1"
}
- 可在控制台内运行如下命令以重新加载
~/.bashrc 中的命令:
Bashsource ~/.bashrc
Windows
- 在(VSCode 中的)Powershell 内运行:
powershellNew-Item -Path $PROFILE -Type File -Force
code $PROFILE
- 在打开的
Microsoft.VSCode_profile.ps1 中添加:
powershellfunction cpl {
param([string]$name)
$cppFile = ".\$name.cpp"
$exeFile = ".\$name.exe"
if (-not (Test-Path $cppFile)) {
Write-Error "Error: $cppFile not found"; return
}
g++ "$cppFile" -o "$exeFile" -O2 -std=c++14 -static -Wall -Wextra
if ($LASTEXITCODE -eq 0) {
Write-Host "Compiled $cppFile" -ForegroundColor Green
}
}
function run {
param([string]$name)
cpl $name
if ($LASTEXITCODE -eq 0 -and (Test-Path ".\$name.exe")) {
Write-Host "Running .\$name.exe`n" -ForegroundColor Cyan
$sw = [System.Diagnostics.Stopwatch]::StartNew()
& ".\$name.exe"
$sw.Stop()
Write-Host "`nTime: $($sw.Elapsed.TotalSeconds.ToString('0.000')) s" -ForegroundColor Yellow
}
}
- 可在(VSCode 中的)Powershell 内运行如下命令以重新加载 PowerShell 配置文件:
powershell. $PROFILE
缺省源文件
VSCode cpp.json
JSON "C++ Template": {
"prefix": "#cpp",
"body": [
"#include<bits/stdc++.h>",
"using namespace std;",
"#define int long long",
"#define ull unsigned long long",
"#define pb push_back",
"#define pii pair<int,int>",
"#define p3i pair<int,pii>",
"#define fi first",
"#define se second",
"#define all(a) (a).begin(),(a).end()",
"const int inf=0x3f3f3f3f, llinf=0x3f3f3f3f3f3f3f3f;",
"namespace IO",
"{",
" bool read(int &x){ x=0; char c=getchar(); bool f=0; while(!isdigit(c)){ f|=(c=='-'); if(c==EOF) return 0; c=getchar(); }",
" while(isdigit(c)){ x=(x<<3)+(x<<1)+(c^48); c=getchar(); } if(f) x=-x; return 1; }",
" bool read(string &s){ s=\"\"; char c=getchar(); while(!isprint(c) || isspace(c)){ if(c==EOF) return 0; c=getchar(); }",
" while(isprint(c) && !isspace(c)){ s+=c; c=getchar(); } return 1; }",
" bool read(char &c){ c=getchar(); while(!isprint(c) || isspace(c)){ if(c==EOF) return 0; c=getchar(); } return 1; }",
" template<typename T,typename... U> bool read(T &x,U&... y){ if(!read(x)) return 0; return read(y...); }",
" void write(int x){ if(x<0){ putchar('-'); x=-x; } string s=\"\"; do{ s+=x%10^48; x/=10; }while(x); reverse(all(s)); for(char c:s) putchar(c); }",
" void write(char c){ putchar(c); } void write(const char *s){ while(*s) putchar(*s++); } void write(string x){ for(char c:x) putchar(c); }",
" template<typename T,typename... U> void write(T x,U... y){ write(x); write(y...); }",
" template<typename T,typename... U> void writeln(T x,U... y){ write(x,y...); puts(\"\"); }",
"}",
"namespace W_C_B_H",
"{",
" using namespace IO;",
" void main()",
" {",
" }",
"}",
"signed main()",
"{",
" // freopen(\".in\",\"r\",stdin);",
" // freopen(\".out\",\"w\",stdout);",
" W_C_B_H::main();",
" return 0;",
"}",
],
"description": "C++ 缺省源"
}
Dev-C++
C++#include<bits/stdc++.h>
using namespace std;
#define int long long
#define ull unsigned long long
#define pb push_back
#define pii pair<int,int>
#define p3i pair<int,pii>
#define fi first
#define se second
#define all(a) (a).begin(),(a).end()
const int inf=0x3f3f3f3f, llinf=0x3f3f3f3f3f3f3f3f;
namespace IO
{
bool read(int &x){ x=0; char c=getchar(); bool f=0; while(!isdigit(c)){ f|=(c=='-'); if(c==EOF) return 0; c=getchar(); }
while(isdigit(c)){ x=(x<<3)+(x<<1)+(c^48); c=getchar(); } if(f) x=-x; return 1; }
bool read(string &s){ s=""; char c=getchar(); while(!isprint(c) || isspace(c)){ if(c==EOF) return 0; c=getchar(); }
while(isprint(c) && !isspace(c)){ s+=c; c=getchar(); } return 1; }
bool read(char &c){ c=getchar(); while(!isprint(c) || isspace(c)){ if(c==EOF) return 0; c=getchar(); } return 1; }
template<typename T,typename... U> bool read(T &x,U&... y){ if(!read(x)) return 0; return read(y...); }
void write(int x){ if(x<0){ putchar('-'); x=-x; } string s=""; do{ s+=x%10^48; x/=10; }while(x); reverse(all(s)); for(char c:s) putchar(c); }
void write(char c){ putchar(c); } void write(const char *s){ while(*s) putchar(*s++); } void write(string x){ for(char c:x) putchar(c); }
template<typename T,typename... U> void write(T x,U... y){ write(x); write(y...); }
template<typename T,typename... U> void writeln(T x,U... y){ write(x,y...); puts(""); }
}
namespace W_C_B_H
{
using namespace IO;
void main()
{
}
}
signed main()
{
// freopen(".in","r",stdin);
// freopen(".out","w",stdout);
W_C_B_H::main();
return 0;
}