Last active
June 2, 2017 20:35
-
-
Save madalinignisca/422477bd0b153085ffbda791495f8355 to your computer and use it in GitHub Desktop.
Comparison returning the sum of 2 numbers read on CLI in many programming languages (looks like JavaScript is not so friendly...)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
#include <string.h> | |
#include <math.h> | |
#include <stdlib.h> | |
int solveMeFirst(int a, int b) { | |
return a+b; | |
} | |
int main() { | |
int num1,num2; | |
scanf("%d %d",&num1,&num2); | |
int sum; | |
sum = solveMeFirst(num1,num2); | |
printf("%d",sum); | |
return 0; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <cmath> | |
#include <cstdio> | |
#include <vector> | |
#include <iostream> | |
#include <algorithm> | |
using namespace std; | |
int solveMeFirst(int a, int b) { | |
return a+b; | |
} | |
int main() { | |
int num1, num2; | |
int sum; | |
cin>>num1>>num2; | |
sum = solveMeFirst(num1,num2); | |
cout<<sum; | |
return 0; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Collections.Generic; | |
using System.IO; | |
class Solution { | |
static int solveMeFirst(int a, int b) { | |
return a+b; | |
} | |
static void Main(String[] args) { | |
int val1 = Convert.ToInt32(Console.ReadLine()); | |
int val2 = Convert.ToInt32(Console.ReadLine()); | |
int sum = solveMeFirst(val1,val2); | |
Console.WriteLine(sum); | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import "fmt" | |
func solveMeFirst(a uint32,b uint32) uint32{ | |
return (a+b) | |
} | |
func main() { | |
var a, b, res uint32 | |
fmt.Scanf("%v\n%v", &a,&b) | |
res = solveMeFirst(a,b) | |
fmt.Println(res) | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.io.*; | |
import java.util.*; | |
import java.text.*; | |
import java.math.*; | |
import java.util.regex.*; | |
public class Solution { | |
static int solveMeFirst(int a, int b) { | |
return a+b; | |
} | |
public static void main(String[] args) { | |
Scanner in = new Scanner(System.in); | |
int a; | |
a = in.nextInt(); | |
int b; | |
b = in.nextInt(); | |
int sum; | |
sum = solveMeFirst(a, b); | |
System.out.println(sum); | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 solveMeFirst(a, b) { | |
return a+b; | |
} | |
function main() { | |
var a = parseInt(readLine()); | |
var b = parseInt(readLine());; | |
var res = solveMeFirst(a, b); | |
console.log(res); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
HAI 1.2 | |
HOW IZ I SOLVEMEFIRST YR NUM1 AN YR NUM2 | |
FOUND YR SUM OF NUM1 AN NUM2 | |
IF U SAY SO | |
I HAS A Num1 | |
I HAS A Num2 | |
I HAS A Res | |
GIMMEH Num1 | |
GIMMEH Num2 | |
Res R I IZ SOLVEMEFIRST YR Num1 AN YR Num2 MKAY | |
VISIBLE Res | |
KTHXBYE |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function solveMeFirst($a,$b){ | |
return $a + $b; | |
} | |
$handle = fopen ("php://stdin","r"); | |
$_a = fgets($handle); | |
$_b = fgets($handle); | |
$sum = solveMeFirst((int)$_a,(int)$_b); | |
print ($sum); | |
fclose($handle); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def solveMeFirst(a,b): | |
return a+b | |
num1 = int(input()) | |
num2 = int(input()) | |
res = solveMeFirst(num1,num2) | |
print(res) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def solveMeFirst (a, b) | |
# Hint: Type return a+b below | |
end | |
val1 = gets.to_i | |
val2 = gets.to_i | |
sum = solveMeFirst(val1,val2) | |
print (sum) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
object Solution { | |
def main(args: Array[String]) { | |
println(io.Source.stdin.getLines().take(2).map(_.toInt).sum) | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
read a | |
read b | |
echo $(($a + $b)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I think if I would be able to return in time, I'd learn Scala instead of JavaScript and PHP...