步骤
VS --》 工具–》 代码片段管理器 --》 Visual C++
快捷代码格式-C模板
<?xml version="1.0" encoding="utf-8"?>
<CodeSnippets xmlns="http://schemas.microsoft.com/VisualStudio/2019/CodeSnippet">
<CodeSnippet Format="1.0.0">
<Header>
<Title>#1</Title>
<Shortcut>#1</Shortcut>
<Description>c语言main函数</Description>
<Author>Microsoft Corporation</Author>
<SnippetTypes>
<SnippetType>Expansion</SnippetType>
<SnippetType>SurroundsWith</SnippetType>
</SnippetTypes>
</Header>
<Snippet>
<Declarations>
<Literal>
<ID>expression</ID>
<ToolTip>要计算的表达式</ToolTip>
<Default>true</Default>
</Literal>
</Declarations>
<Code Language="cpp"><![CDATA[#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <time.h>
#include <Windows.h>
int main(void)
{
$selected$$end$
system("pause");
return EXIT_SUCCESS;
}
]]>
</Code>
</Snippet>
</CodeSnippet>
</CodeSnippets>
快捷代码格式C++模板
<?xml version="1.0" encoding="utf-8"?>
<CodeSnippets xmlns="http://schemas.microsoft.com/VisualStudio/2019/CodeSnippet">
<CodeSnippet Format="1.0.0">
<Header>
<Title>#2</Title>
<Shortcut>#2</Shortcut>
<Description>c++语言main函数</Description>
<Author>Microsoft Corporation</Author>
<SnippetTypes>
<SnippetType>Expansion</SnippetType>
<SnippetType>SurroundsWith</SnippetType>
</SnippetTypes>
</Header>
<Snippet>
<Declarations>
<Literal>
<ID>expression</ID>
<ToolTip>要计算的表达式</ToolTip>
<Default>true</Default>
</Literal>
</Declarations>
<Code Language="cpp"><![CDATA[#define _CRT_SECURE_NO_WARNINGS
#include<iostream>
using namespace std;
int main()
{
$selected$$end$
system("pause");
return EXIT_SUCCESS;
}]]>
</Code>
</Snippet>
</CodeSnippet>
</CodeSnippets>
快捷代码格式冒泡函数模板
<?xml version="1.0" encoding="utf-8"?>
<CodeSnippets xmlns="http://schemas.microsoft.com/VisualStudio/2019/CodeSnippet">
<CodeSnippet Format="1.0.0">
<Header>
<Title>#BubbleSort</Title>
<Shortcut>#BubbleSort</Shortcut>
<Description>冒泡排序</Description>
<Author>Microsoft Corporation</Author>
<SnippetTypes>
<SnippetType>Expansion</SnippetType>
<SnippetType>SurroundsWith</SnippetType>
</SnippetTypes>
</Header>
<Snippet>
<Declarations>
<Literal>
<ID>expression</ID>
<ToolTip>要计算的表达式</ToolTip>
<Default>true</Default>
</Literal>
</Declarations>
<Code Language="cpp">
<![CDATA[
void BubbleSort(int * src,int len)
{
for(int i=0;i<len-1;i++)
{
for(int j=0;j<len-1-i;j++)
{
if(src[j]>src[j+1])
{
int temp = src[j];
src[j] = src[j+1];
src[j+1] = temp;
}
}
}
}
]]>
</Code>
</Snippet>
</CodeSnippet>
</CodeSnippets>