zoukankan      html  css  js  c++  java
  • Sublime Text3 配置C++(附oj刷题常用模板)

    下载对应平台的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

    20170812150246958137367.png

    文件内容如下:

    {
        "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++程序测试一下
    20170812150247043771743.png

    Windows下配置

    c++环境设置

    1. 在系统环境变量Path中添加MinGW > bin所在目录,
      点击下载MinGW
      20170814150272417980528.png

    2. 同样在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键

    效果如下

    20170812150247176496944.gif

    地址 http://sshpark.com.cn/
  • 相关阅读:
    负外边距--转载
    研究Dropbox Server端文件系统
    Bluetooth Profile for iPhone from the functional perspectives
    Somebody That I Used to Know
    复合查询
    聚合查询
    Filter查询
    ES基本查询
    ES版本控制
    ES基本操作
  • 原文地址:https://www.cnblogs.com/huangjiaming/p/7364004.html
Copyright © 2011-2022 走看看