The Perse Coding Team Challenge

 
 

This video, kindly made by Chris Roffey from Bebras UK, nicely demonstrates how to use the code editor/grader on this site:

https://youtu.be/hg2DUIUpmus

All inputs should be read from standard in and outputs printed to standard out.

These examples all read a single integer and print double that number out.

Python:
num = int(input())
print(num * 2)
Java:
import java.io.*;
import java.util.*;

public class Solution {
public static void main(String[] args) {
    // Enter your code here
    Scanner scanner = new Scanner(System.in);
int num = scanner.nextInt();
System.out.println(num * 2);
}
}

C#:
using System;
using System.Collections.Generic;
using System.IO;

class Solution {
static void Main(String[] args) {
// Enter your code here
int num = Int32.Parse(Console.ReadLine());
Console.WriteLine(num * 2);
}
}

VB.NET:

Module Solution
Sub Main()
' Enter your code here
Dim num As Integer = Integer.Parse(Console.ReadLine())
Console.WriteLine(num * 2)
End Sub
End Module

JavaScript (Node.js)

process.stdin.resume();
process.stdin.setEncoding('ascii');
var input_stdin = "";
var input_stdin_array = "";
var input_currentline = 0;

process.stdin.on('data', function (data) {
    input_stdin += data;
});

process.stdin.on('end', function () {
    input_stdin_array = input_stdin.split("\n");
main();
});

function readLine() {
    return input_stdin_array[input_currentline++];
}

function main() {
// Enter your code here
    var num = parseInt(readLine());
    console.log(num * 2);
}

C++ 11:

#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
using namespace std;

int main() {
// Enter your code here
std::string sNum;
std::getline(std::cin, sNum);
int num = std::stoi(sNum);
std:cout << num * 2 << "\n";
return 0;
}

Note: one advantage of using getline for c++ input is that when multiple values are provided on one line of input (e.g. 2 3 5 7) then you can easily read through to the next delimeter e.g.

std::getline(std::cin, sNum, ' ');