Sublime Text3 配置C++(附oj刷题常用模板)
2024-09-30 08:09:10
下载对应平台的sublime
sublime最新版下载, 字体样式个人喜欢Consolas
, 另附注册码:
—– BEGIN LICENSE —–
TwitterInc
200 User License
EA7E-890007
1D77F72E 390CDD93 4DCBA022 FAF60790
61AA12C0 A37081C5 D0316412 4584D136
94D7F7D4 95BC8C1C 527DA828 560BB037
D1EDDD8C AE7B379F 50C9D69D B35179EF
2FE898C4 8E4277A8 555CE714 E1FB0E43
D5D52613 C3D12E98 BC49967F 7652EED2
9D2D2E61 67610860 6D338B72 5CF95C69
E36B85CC 84991F19 7575D828 470A92AB
—— END LICENSE ——
Mac下配置
选择Tools > Build System > New Build System
创建一个编译模板,名字命名为C++11
文件内容如下:
{
"cmd": ["g++", "${file}", "-o", "${file_path}/${file_base_name}"],
"file_regex": "^(..[^:]*):([0-9]+):?([0-9]+)?:? (.*)$",
"working_dir": "${file_path}",
"selector": "source.c, source.c++",
"variants":
[
{
"name": "Run",
"cmd": ["bash", "-c", "g++ -std=c++11 '${file}' -o 'a' && open -a terminal '${file_path}/a'"]
}
]
}
配置中的open -a terminal
指的是从终端打开该文件, 如果不需要,可以将其去掉。
编写一个简单的c++
程序测试一下
Windows下配置
c++环境设置
在系统环境变量
Path
中添加MinGW > bin
所在目录,
点击下载MinGW
同样在
Tools > Build System > New Build System
新建编译模板,保存为C++11.sublime-build
内容为:
C++.sublime-build
{
"encoding": "utf-8",
"working_dir": "$file_path",
"shell_cmd": "g++ -Wall \"$file_name\" -o \"$file_base_name\"",
"file_regex": "^(..[^:]*):([0-9]+):?([0-9]+)?:? (.*)$",
"selector": "source.c++",
"variants":
[
{
"name": "Run",
"shell_cmd": "g++ -Wall \"$file\" -o \"$file_base_name\" && start cmd /c \"\"${file_path}/${file_base_name}\" & pause\""
}
]
}
oj刷题常用模版
sublime中可以添加代码片段
创建方法:Tools (工具)> Developer > New Snippet(新片段)
1、在新建的文件中添加如下内容
<snippet>
<content>
<![CDATA[
#pragma comment(linker, "/STACK:1024000000,1024000000")
#include <stdio.h>
#include <iostream>
#include <cstdlib>
#include <cmath>
#include <cctype>
#include <string>
#include <cstring>
#include <algorithm>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <ctime>
#include <vector>
#include <fstream>
#include <list>
#include <iomanip>
#include <numeric>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define ms(s) memset(s, 0, sizeof(s))
const int inf = 0x3f3f3f3f;
#define LOCAL
int main(int argc, char * argv[])
{
#ifdef LOCAL
freopen("/Users/huangjiaming/Documents/Algorithm/oj/data.in", "r", stdin);
//freopen("/Users/huangjiaming/Documents/Algorithm/oj/data.out", "w", stdout);
#endif
${1:/* code */}
while (~scanf("%d", ${2:/* var */}))
{
}
return 0;
}]]>
</content>
<!-- Optional: Set a tabTrigger to define how to trigger the snippet -->
<tabTrigger>acm</tabTrigger>
<!-- Optional: Set a scope to limit where the snippet will trigger -->
<scope>source.c++</scope>
</snippet>
2、保存为acm.sublime-snippet
3、使用方法,在你的c++文件中输入acm
关键字,再按下Tap键
效果如下
最新文章
- Guava Supplier实例
- 【Win10 开发】读取PDF文档
- 搭建eclipse+github开发环境
- hdu 2964 Prime Bases(简单数学题)
- 手把手教你WEB套打程序开发
- 【暑假】[实用数据结构]前缀树 Trie
- Ora-12154:无法解析连接字符串
- 延迟加载并渐现内容的jquery插件lazyFade
- php 图片上传预览(转)
- Android开发之漫漫长途 Ⅳ——Activity的显示之ViewRootImpl初探
- awk进阶整理
- 【移动开发】一张图搞定Activity和Fragment的生命周期
- .Net语言 APP开发平台——Smobiler学习日志:基于Access数据库的Demo
- C++ 浅拷贝与深拷贝探究
- NSL:SOFM神经网络实现预测哪个样本与哪个样本处在同一层,从而科学规避我国煤矿突水灾难—Jason niu
- awt多线程聊天
- GO语言的进阶之路-网络安全之proxy
- AndroidStudio 之 Inter x86 Emulator Accelerator(Haxm installer) - not compatible with windows
- 跟bWAPP学WEB安全(PHP代码)--认证绕过与会话管理
- ML: 聚类算法R包 - 模型聚类