Ugh, tired of writing same code again and again in c++, well if you're using Vscode we have snippets for you.
- Open your VS code Editor.
- Press
ctrl+shift+p
orcmd+shift+p
and search for snippets. - Select "Preferences: Configure User Snippets".
- then, type "New Global Snippets file" and select that.
- type file name as you're desire but, for now let's go with "cppSnippets".
- now go to this link and copy and paste the code.
- save the file and you're good to go.
Now after following above steps you just need to type snippets prefix and wallah 😎.
for example
// "iiom","mi","#include","main" type this to get a template with including iostream library
// iiom --> include iostream and main function
#include <iostream>
using namespace std;
int main()
{
/* code */
return 0;
}
// "ibm", "mi", "main","#include" type this to get a template with stdc++ included from bits within main function
// ibm --> include bits and main function
#include <bits/stdc++.h>
using namespace std;
int main()
{
/* code */
return 0;
}
// "itc" for input test case template as for
// competitive programming or problems
int t;
cin >> t;
while (t--)
{
// Code
}
for example
// "for_2", "f_2" type this to get nested two for loops
// for_2 , f_2 --> two nested for loops
for (int i = 0; i < n; i++)
{
for (int j = 0; j < m; j++)
{
// code
}
/*code*/ // pointer comes here at the end
}
// "for_3", "f_3" type this to get nested three for loops
// for_3 , f_3 --> three nested for loops
for (int i; i < n; i++)
{
for (int j; j < m; j++)
{
for (int k; k < o; k++)
{
// code
}
// code
}
// code // Pointer comes here at the end
}
if (/*condition 1*/)
{
if (/*condition 2*/)
{
/*code*/
}
/*code*/ // pointer comes here at the end
}
// "if_3" type this to get nested if template
// if_3 --> three times nested if
if (/*condition 1*/)
{
if (/*condition 2*/)
{
if (/*condition 3*/)
{
/*code*/
}
/*code*/
}
/*code*/ // pointer comes here at the end
}
Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.
Please make sure to update tests as appropriate.