cft

Competitive Programming setup for VS Code using C++

Today Competitive Programming is the new craze among university students and budding software engineers. It provides the best platform to showcase and test your problem-solving skills and programming skills.


user

Prabanjan M

3 years ago | 3 min read

Hello ๐Ÿ‘‹ world !

Today Competitive Programming is the new craze among university students and budding software engineers. It provides the best platform to showcase and test your problem-solving skills and programming skills.

So many companies have considered it as a way for choosing the candidates with their own contests. So to excel in it, you need programming skills and practice that two are mandatory. But sometimes the rankings can differ in minute time difference. And to gain an edge over these kinds of situations you need a great IDE setup.

I assume that you already have the C++ compiler so this article only explains about the VS Code setup.
If you don't have a proper C++ compiler then mention it in the comments I will help you with them.

Why VS Code ?

VS Code is without any doubt the best IDE a developer can get his hands on. But we should not forget that it is technical a lightweight text editor. But the extensions is all we need. It allows a level of customization that you can not even imagine in other similar IDE or text editors.

Customization is the most favorite thing it is also the most popular IDE among developers and that being said the extensions available make it the most productive. I will soon share some cool extensions for your VS Code.

Step 1

First thing is for you to create a folder ๐Ÿ“‚. This is the folder ๐Ÿ“‚ which you will be using for your C / C++ programs.

Step 2

Downloading the necessary extensions. It is better to download the

C/C++ Extension Pack - Visual Studio MarketplaceExtension for Visual Studio Code - Popular extensions for C++ development in Visual Studio Code.marketplace.visualstudio.com

But if you don't want to it's completely fine.
But you need to have these mandatory extensions

Step 3

This is the most important step in the entire process. VS Code does not implicitly support C++ so you need to configure the build task and launch task. But no need I have got you covered. Just head over to this GitHub repository. This repository was created for absolute beginners and have some amazing resources to get you started. Head over to this repository and clone it or download it to your local system.

Then just copy and paste the .vscode folder within the folder that you previously created.

Forks ยท prabanjanraja/Competitive-Programming-MaterialsContribute to prabanjanraja/Competitive-Programming-Materials development by creating an account on GitHub.github.com. Now you can run any C/C++ program just by pressing F5 this is enough for participating in a contest but not for winning it. So hang on I still have some amazing things for you.

Live snippets

Live snippets are a great way to improve your coding speed when it comes to contests. So I have an amazing one just for you. The file can be awfully long but if you could understand it you will save a great amount of time.

If you have trouble understanding the file mention it in the comments I will make a separate article for that.
So head over to this link or to the folder that you have previously cloned to your local system and copy the contents of the boilerplates.cpp file.

Competitive-Programming-Materials/Boilerplates.cpp at master ยท prabanjanraja/Competitive-Programming-MaterialsContribute to prabanjanraja/Competitive-Programming-Materials development by creating an account on GitHub.github.com

Then head over to this page to transform the code into the suitable live snippet syntax.

snippet generatorSnippet generator for Visual Studio Code, Sublime Text and Atom. Enjoy :-)

Then press F1 in your VS Code and select Preferences: Configure user snippets and choose cpp.json and paste the contents you copied with in the { } and save the file.

Now to see the magic just create a C++ file within the folder and start typing your trigger word (what you gave in the snippet generator page) and VS Code will show you the list of available snippets with their description. Just select the snippet that we just saved and hit Enter. You will have almost everything you need. Now all that is left for you is to just write the solution for the problem.

Dont't forget to create a input.txt file with in your folder cause you will be giving all the input through this file.

Now create 2 files input.txt and output.txt in the same folder, these folders should be in the root folder. The final thing is to create the view. Just head over to the View>Editor Layout in the menu bar, and I am pretty you will find it. Your VS Code should now look like this.

The input goes to the top right and the output to the bottom right.

Hope this article helped you and sparked your curiosity to learn and practice CP. Do mention your views and opinions in the comments. Do remember that these editor setups can't help you win the contests without your best efforts.

Upvote


user
Created by

Prabanjan M

I am a final year student passionate about learning. I started this blog to help other students who are struggling, I share my knowledge on topics which I learned in the hard way so that others can learn it in the easy way.


people
Post

Upvote

Downvote

Comment

Bookmark

Share


Related Articles