Instruction stringlengths 45 106 | input_code stringlengths 1 13.7k | output_code stringlengths 1 13.7k |
|---|---|---|
Maintain the same structure and functionality when rewriting this code in C. | import std.stdio, std.conv;
void main() {
immutable text = "100";
foreach (base; 2 .. 21)
writefln("String '%s' in base %d is %d in base 10" ,
text, base, to!int(text, base));
}
| #include <stdio.h>
int main()
{
int num;
sscanf("0123459", "%d", &num);
printf("%d\n", num);
sscanf("abcf123", "%x", &num);
printf("%d\n", num);
sscanf("7651", "%o", &num);
printf("%d\n", num);
return 0;
}
|
Translate this program into C# but keep the logic exactly as in D. | import std.stdio, std.conv;
void main() {
immutable text = "100";
foreach (base; 2 .. 21)
writefln("String '%s' in base %d is %d in base 10" ,
text, base, to!int(text, base));
}
| using System;
class Program
{
static void Main()
{
var value = "100";
var fromBases = new[] { 2, 8, 10, 16 };
var toBase = 10;
foreach (var fromBase in fromBases)
{
Console.WriteLine("{0} in base {1} is {2} in base {3}",
value, fromBase, Conve... |
Produce a language-to-language conversion: from D to C++, same semantics. | import std.stdio, std.conv;
void main() {
immutable text = "100";
foreach (base; 2 .. 21)
writefln("String '%s' in base %d is %d in base 10" ,
text, base, to!int(text, base));
}
| #include <iostream>
#include <sstream>
int main()
{
int num;
std::istringstream("0123459") >> num;
std::cout << num << std::endl;
std::istringstream("0123459") >> std::dec >> num;
std::cout << num << std::endl;
std::istringstream("abcf123") >> std::hex >> num;
std::cout << num << std::endl;
std:... |
Translate this program into Java but keep the logic exactly as in D. | import std.stdio, std.conv;
void main() {
immutable text = "100";
foreach (base; 2 .. 21)
writefln("String '%s' in base %d is %d in base 10" ,
text, base, to!int(text, base));
}
| Scanner sc = new Scanner(System.in);
sc.useRadix(base);
sc.nextInt();
|
Change the following D code into Python without altering its purpose. | import std.stdio, std.conv;
void main() {
immutable text = "100";
foreach (base; 2 .. 21)
writefln("String '%s' in base %d is %d in base 10" ,
text, base, to!int(text, base));
}
| >>> text = '100'
>>> for base in range(2,21):
print ("String '%s' in base %i is %i in base 10"
% (text, base, int(text, base)))
String '100' in base 2 is 4 in base 10
String '100' in base 3 is 9 in base 10
String '100' in base 4 is 16 in base 10
String '100' in base 5 is 25 in base 10
String '1... |
Generate a Go translation of this D snippet without changing its computational steps. | import std.stdio, std.conv;
void main() {
immutable text = "100";
foreach (base; 2 .. 21)
writefln("String '%s' in base %d is %d in base 10" ,
text, base, to!int(text, base));
}
| package main
import (
"fmt"
"math/big"
"strconv"
)
func main() {
x, _ := strconv.Atoi("13")
fmt.Println(x)
x64, _ := strconv.ParseInt("3c2", 19, 64)
fmt.Println(x64)
fmt.Sscanf("1101", "%b", &x)
fmt.Println(x)
fmt.S... |
Produce a language-to-language conversion: from Elixir to C, same semantics. | iex(1)> String.to_integer("1000")
1000
iex(2)> String.to_integer("1000",2)
8
iex(3)> String.to_integer("1000",8)
512
iex(4)> String.to_integer("1000",16)
4096
iex(5)> String.to_integer("ffff",16)
65535
| #include <stdio.h>
int main()
{
int num;
sscanf("0123459", "%d", &num);
printf("%d\n", num);
sscanf("abcf123", "%x", &num);
printf("%d\n", num);
sscanf("7651", "%o", &num);
printf("%d\n", num);
return 0;
}
|
Ensure the translated C# code behaves exactly like the original Elixir snippet. | iex(1)> String.to_integer("1000")
1000
iex(2)> String.to_integer("1000",2)
8
iex(3)> String.to_integer("1000",8)
512
iex(4)> String.to_integer("1000",16)
4096
iex(5)> String.to_integer("ffff",16)
65535
| using System;
class Program
{
static void Main()
{
var value = "100";
var fromBases = new[] { 2, 8, 10, 16 };
var toBase = 10;
foreach (var fromBase in fromBases)
{
Console.WriteLine("{0} in base {1} is {2} in base {3}",
value, fromBase, Conve... |
Port the provided Elixir code into C++ while preserving the original functionality. | iex(1)> String.to_integer("1000")
1000
iex(2)> String.to_integer("1000",2)
8
iex(3)> String.to_integer("1000",8)
512
iex(4)> String.to_integer("1000",16)
4096
iex(5)> String.to_integer("ffff",16)
65535
| #include <iostream>
#include <sstream>
int main()
{
int num;
std::istringstream("0123459") >> num;
std::cout << num << std::endl;
std::istringstream("0123459") >> std::dec >> num;
std::cout << num << std::endl;
std::istringstream("abcf123") >> std::hex >> num;
std::cout << num << std::endl;
std:... |
Port the following code from Elixir to Java with equivalent syntax and logic. | iex(1)> String.to_integer("1000")
1000
iex(2)> String.to_integer("1000",2)
8
iex(3)> String.to_integer("1000",8)
512
iex(4)> String.to_integer("1000",16)
4096
iex(5)> String.to_integer("ffff",16)
65535
| Scanner sc = new Scanner(System.in);
sc.useRadix(base);
sc.nextInt();
|
Ensure the translated Go code behaves exactly like the original Elixir snippet. | iex(1)> String.to_integer("1000")
1000
iex(2)> String.to_integer("1000",2)
8
iex(3)> String.to_integer("1000",8)
512
iex(4)> String.to_integer("1000",16)
4096
iex(5)> String.to_integer("ffff",16)
65535
| package main
import (
"fmt"
"math/big"
"strconv"
)
func main() {
x, _ := strconv.Atoi("13")
fmt.Println(x)
x64, _ := strconv.ParseInt("3c2", 19, 64)
fmt.Println(x64)
fmt.Sscanf("1101", "%b", &x)
fmt.Println(x)
fmt.S... |
Generate an equivalent C version of this F# code. | let value = "100"
let fromBases = [ 2; 8; 10; 16 ]
let values = Seq.initInfinite (fun i -> value)
Seq.zip fromBases (Seq.zip values fromBases |> Seq.map (System.Convert.ToInt32))
|> Seq.iter (
fun (fromBase, valueFromBaseX) ->
printfn "%s in base %i is %i in base 10" value fromBase valueFromBaseX)
| #include <stdio.h>
int main()
{
int num;
sscanf("0123459", "%d", &num);
printf("%d\n", num);
sscanf("abcf123", "%x", &num);
printf("%d\n", num);
sscanf("7651", "%o", &num);
printf("%d\n", num);
return 0;
}
|
Please provide an equivalent version of this F# code in C#. | let value = "100"
let fromBases = [ 2; 8; 10; 16 ]
let values = Seq.initInfinite (fun i -> value)
Seq.zip fromBases (Seq.zip values fromBases |> Seq.map (System.Convert.ToInt32))
|> Seq.iter (
fun (fromBase, valueFromBaseX) ->
printfn "%s in base %i is %i in base 10" value fromBase valueFromBaseX)
| using System;
class Program
{
static void Main()
{
var value = "100";
var fromBases = new[] { 2, 8, 10, 16 };
var toBase = 10;
foreach (var fromBase in fromBases)
{
Console.WriteLine("{0} in base {1} is {2} in base {3}",
value, fromBase, Conve... |
Produce a functionally identical C++ code for the snippet given in F#. | let value = "100"
let fromBases = [ 2; 8; 10; 16 ]
let values = Seq.initInfinite (fun i -> value)
Seq.zip fromBases (Seq.zip values fromBases |> Seq.map (System.Convert.ToInt32))
|> Seq.iter (
fun (fromBase, valueFromBaseX) ->
printfn "%s in base %i is %i in base 10" value fromBase valueFromBaseX)
| #include <iostream>
#include <sstream>
int main()
{
int num;
std::istringstream("0123459") >> num;
std::cout << num << std::endl;
std::istringstream("0123459") >> std::dec >> num;
std::cout << num << std::endl;
std::istringstream("abcf123") >> std::hex >> num;
std::cout << num << std::endl;
std:... |
Please provide an equivalent version of this F# code in Java. | let value = "100"
let fromBases = [ 2; 8; 10; 16 ]
let values = Seq.initInfinite (fun i -> value)
Seq.zip fromBases (Seq.zip values fromBases |> Seq.map (System.Convert.ToInt32))
|> Seq.iter (
fun (fromBase, valueFromBaseX) ->
printfn "%s in base %i is %i in base 10" value fromBase valueFromBaseX)
| Scanner sc = new Scanner(System.in);
sc.useRadix(base);
sc.nextInt();
|
Please provide an equivalent version of this F# code in Python. | let value = "100"
let fromBases = [ 2; 8; 10; 16 ]
let values = Seq.initInfinite (fun i -> value)
Seq.zip fromBases (Seq.zip values fromBases |> Seq.map (System.Convert.ToInt32))
|> Seq.iter (
fun (fromBase, valueFromBaseX) ->
printfn "%s in base %i is %i in base 10" value fromBase valueFromBaseX)
| >>> text = '100'
>>> for base in range(2,21):
print ("String '%s' in base %i is %i in base 10"
% (text, base, int(text, base)))
String '100' in base 2 is 4 in base 10
String '100' in base 3 is 9 in base 10
String '100' in base 4 is 16 in base 10
String '100' in base 5 is 25 in base 10
String '1... |
Maintain the same structure and functionality when rewriting this code in Go. | let value = "100"
let fromBases = [ 2; 8; 10; 16 ]
let values = Seq.initInfinite (fun i -> value)
Seq.zip fromBases (Seq.zip values fromBases |> Seq.map (System.Convert.ToInt32))
|> Seq.iter (
fun (fromBase, valueFromBaseX) ->
printfn "%s in base %i is %i in base 10" value fromBase valueFromBaseX)
| package main
import (
"fmt"
"math/big"
"strconv"
)
func main() {
x, _ := strconv.Atoi("13")
fmt.Println(x)
x64, _ := strconv.ParseInt("3c2", 19, 64)
fmt.Println(x64)
fmt.Sscanf("1101", "%b", &x)
fmt.Println(x)
fmt.S... |
Produce a functionally identical C code for the snippet given in Factor. | IN: math.parser
: oct> ( str -- n/f ) 8 base> ; inline
| #include <stdio.h>
int main()
{
int num;
sscanf("0123459", "%d", &num);
printf("%d\n", num);
sscanf("abcf123", "%x", &num);
printf("%d\n", num);
sscanf("7651", "%o", &num);
printf("%d\n", num);
return 0;
}
|
Convert the following code from Factor to C#, ensuring the logic remains intact. | IN: math.parser
: oct> ( str -- n/f ) 8 base> ; inline
| using System;
class Program
{
static void Main()
{
var value = "100";
var fromBases = new[] { 2, 8, 10, 16 };
var toBase = 10;
foreach (var fromBase in fromBases)
{
Console.WriteLine("{0} in base {1} is {2} in base {3}",
value, fromBase, Conve... |
Write the same algorithm in C++ as shown in this Factor implementation. | IN: math.parser
: oct> ( str -- n/f ) 8 base> ; inline
| #include <iostream>
#include <sstream>
int main()
{
int num;
std::istringstream("0123459") >> num;
std::cout << num << std::endl;
std::istringstream("0123459") >> std::dec >> num;
std::cout << num << std::endl;
std::istringstream("abcf123") >> std::hex >> num;
std::cout << num << std::endl;
std:... |
Change the programming language of this snippet from Factor to Java without modifying what it does. | IN: math.parser
: oct> ( str -- n/f ) 8 base> ; inline
| Scanner sc = new Scanner(System.in);
sc.useRadix(base);
sc.nextInt();
|
Preserve the algorithm and functionality while converting the code from Factor to Python. | IN: math.parser
: oct> ( str -- n/f ) 8 base> ; inline
| >>> text = '100'
>>> for base in range(2,21):
print ("String '%s' in base %i is %i in base 10"
% (text, base, int(text, base)))
String '100' in base 2 is 4 in base 10
String '100' in base 3 is 9 in base 10
String '100' in base 4 is 16 in base 10
String '100' in base 5 is 25 in base 10
String '1... |
Keep all operations the same but rewrite the snippet in Go. | IN: math.parser
: oct> ( str -- n/f ) 8 base> ; inline
| package main
import (
"fmt"
"math/big"
"strconv"
)
func main() {
x, _ := strconv.Atoi("13")
fmt.Println(x)
x64, _ := strconv.ParseInt("3c2", 19, 64)
fmt.Println(x64)
fmt.Sscanf("1101", "%b", &x)
fmt.Println(x)
fmt.S... |
Transform the following Forth implementation into C, maintaining the same output and logic. | : parse#
0. 2SWAP DUP >R >NUMBER NIP NIP
R> <> DUP 0= IF NIP THEN ;
: base#
BASE @ >R BASE ! parse# R> BASE ! ;
| #include <stdio.h>
int main()
{
int num;
sscanf("0123459", "%d", &num);
printf("%d\n", num);
sscanf("abcf123", "%x", &num);
printf("%d\n", num);
sscanf("7651", "%o", &num);
printf("%d\n", num);
return 0;
}
|
Generate an equivalent C# version of this Forth code. | : parse#
0. 2SWAP DUP >R >NUMBER NIP NIP
R> <> DUP 0= IF NIP THEN ;
: base#
BASE @ >R BASE ! parse# R> BASE ! ;
| using System;
class Program
{
static void Main()
{
var value = "100";
var fromBases = new[] { 2, 8, 10, 16 };
var toBase = 10;
foreach (var fromBase in fromBases)
{
Console.WriteLine("{0} in base {1} is {2} in base {3}",
value, fromBase, Conve... |
Maintain the same structure and functionality when rewriting this code in C++. | : parse#
0. 2SWAP DUP >R >NUMBER NIP NIP
R> <> DUP 0= IF NIP THEN ;
: base#
BASE @ >R BASE ! parse# R> BASE ! ;
| #include <iostream>
#include <sstream>
int main()
{
int num;
std::istringstream("0123459") >> num;
std::cout << num << std::endl;
std::istringstream("0123459") >> std::dec >> num;
std::cout << num << std::endl;
std::istringstream("abcf123") >> std::hex >> num;
std::cout << num << std::endl;
std:... |
Convert this Forth block to Java, preserving its control flow and logic. | : parse#
0. 2SWAP DUP >R >NUMBER NIP NIP
R> <> DUP 0= IF NIP THEN ;
: base#
BASE @ >R BASE ! parse# R> BASE ! ;
| Scanner sc = new Scanner(System.in);
sc.useRadix(base);
sc.nextInt();
|
Rewrite the snippet below in Python so it works the same as the original Forth code. | : parse#
0. 2SWAP DUP >R >NUMBER NIP NIP
R> <> DUP 0= IF NIP THEN ;
: base#
BASE @ >R BASE ! parse# R> BASE ! ;
| >>> text = '100'
>>> for base in range(2,21):
print ("String '%s' in base %i is %i in base 10"
% (text, base, int(text, base)))
String '100' in base 2 is 4 in base 10
String '100' in base 3 is 9 in base 10
String '100' in base 4 is 16 in base 10
String '100' in base 5 is 25 in base 10
String '1... |
Ensure the translated Go code behaves exactly like the original Forth snippet. | : parse#
0. 2SWAP DUP >R >NUMBER NIP NIP
R> <> DUP 0= IF NIP THEN ;
: base#
BASE @ >R BASE ! parse# R> BASE ! ;
| package main
import (
"fmt"
"math/big"
"strconv"
)
func main() {
x, _ := strconv.Atoi("13")
fmt.Println(x)
x64, _ := strconv.ParseInt("3c2", 19, 64)
fmt.Println(x64)
fmt.Sscanf("1101", "%b", &x)
fmt.Println(x)
fmt.S... |
Write the same code in C# as shown below in Fortran. | program Example
implicit none
integer :: num
character(32) :: str
str = "0123459"
read(str, "(i10)") num
write(*,*) num
str = "abcf123"
read(str, "(z8)") num
write(*,*) num
str = "7651"
read(str, "(o11)") num
write(*,*) num
str = "1010011010"
r... | using System;
class Program
{
static void Main()
{
var value = "100";
var fromBases = new[] { 2, 8, 10, 16 };
var toBase = 10;
foreach (var fromBase in fromBases)
{
Console.WriteLine("{0} in base {1} is {2} in base {3}",
value, fromBase, Conve... |
Convert the following code from Fortran to C++, ensuring the logic remains intact. | program Example
implicit none
integer :: num
character(32) :: str
str = "0123459"
read(str, "(i10)") num
write(*,*) num
str = "abcf123"
read(str, "(z8)") num
write(*,*) num
str = "7651"
read(str, "(o11)") num
write(*,*) num
str = "1010011010"
r... | #include <iostream>
#include <sstream>
int main()
{
int num;
std::istringstream("0123459") >> num;
std::cout << num << std::endl;
std::istringstream("0123459") >> std::dec >> num;
std::cout << num << std::endl;
std::istringstream("abcf123") >> std::hex >> num;
std::cout << num << std::endl;
std:... |
Convert this Fortran snippet to C and keep its semantics consistent. | program Example
implicit none
integer :: num
character(32) :: str
str = "0123459"
read(str, "(i10)") num
write(*,*) num
str = "abcf123"
read(str, "(z8)") num
write(*,*) num
str = "7651"
read(str, "(o11)") num
write(*,*) num
str = "1010011010"
r... | #include <stdio.h>
int main()
{
int num;
sscanf("0123459", "%d", &num);
printf("%d\n", num);
sscanf("abcf123", "%x", &num);
printf("%d\n", num);
sscanf("7651", "%o", &num);
printf("%d\n", num);
return 0;
}
|
Please provide an equivalent version of this Fortran code in Java. | program Example
implicit none
integer :: num
character(32) :: str
str = "0123459"
read(str, "(i10)") num
write(*,*) num
str = "abcf123"
read(str, "(z8)") num
write(*,*) num
str = "7651"
read(str, "(o11)") num
write(*,*) num
str = "1010011010"
r... | Scanner sc = new Scanner(System.in);
sc.useRadix(base);
sc.nextInt();
|
Convert the following code from Fortran to Python, ensuring the logic remains intact. | program Example
implicit none
integer :: num
character(32) :: str
str = "0123459"
read(str, "(i10)") num
write(*,*) num
str = "abcf123"
read(str, "(z8)") num
write(*,*) num
str = "7651"
read(str, "(o11)") num
write(*,*) num
str = "1010011010"
r... | >>> text = '100'
>>> for base in range(2,21):
print ("String '%s' in base %i is %i in base 10"
% (text, base, int(text, base)))
String '100' in base 2 is 4 in base 10
String '100' in base 3 is 9 in base 10
String '100' in base 4 is 16 in base 10
String '100' in base 5 is 25 in base 10
String '1... |
Produce a functionally identical PHP code for the snippet given in Fortran. | program Example
implicit none
integer :: num
character(32) :: str
str = "0123459"
read(str, "(i10)") num
write(*,*) num
str = "abcf123"
read(str, "(z8)") num
write(*,*) num
str = "7651"
read(str, "(o11)") num
write(*,*) num
str = "1010011010"
r... | <?php
echo +"0123459", "\n"; // prints 123459
echo intval("0123459"), "\n"; // prints 123459
echo hexdec("abcf123"), "\n"; // prints 180154659
echo octdec("7651"), "\n"; // prints 4009
echo bindec("101011001"), "\n"; // prints 345
?>
|
Translate the given Haskell code snippet into C without altering its behavior. | Prelude> read "123459" :: Integer
123459
Prelude> read "0xabcf123" :: Integer
180154659
Prelude> read "0o7651" :: Integer
4009
| #include <stdio.h>
int main()
{
int num;
sscanf("0123459", "%d", &num);
printf("%d\n", num);
sscanf("abcf123", "%x", &num);
printf("%d\n", num);
sscanf("7651", "%o", &num);
printf("%d\n", num);
return 0;
}
|
Rewrite this program in C# while keeping its functionality equivalent to the Haskell version. | Prelude> read "123459" :: Integer
123459
Prelude> read "0xabcf123" :: Integer
180154659
Prelude> read "0o7651" :: Integer
4009
| using System;
class Program
{
static void Main()
{
var value = "100";
var fromBases = new[] { 2, 8, 10, 16 };
var toBase = 10;
foreach (var fromBase in fromBases)
{
Console.WriteLine("{0} in base {1} is {2} in base {3}",
value, fromBase, Conve... |
Convert this Haskell block to C++, preserving its control flow and logic. | Prelude> read "123459" :: Integer
123459
Prelude> read "0xabcf123" :: Integer
180154659
Prelude> read "0o7651" :: Integer
4009
| #include <iostream>
#include <sstream>
int main()
{
int num;
std::istringstream("0123459") >> num;
std::cout << num << std::endl;
std::istringstream("0123459") >> std::dec >> num;
std::cout << num << std::endl;
std::istringstream("abcf123") >> std::hex >> num;
std::cout << num << std::endl;
std:... |
Translate this program into Java but keep the logic exactly as in Haskell. | Prelude> read "123459" :: Integer
123459
Prelude> read "0xabcf123" :: Integer
180154659
Prelude> read "0o7651" :: Integer
4009
| Scanner sc = new Scanner(System.in);
sc.useRadix(base);
sc.nextInt();
|
Keep all operations the same but rewrite the snippet in Python. | Prelude> read "123459" :: Integer
123459
Prelude> read "0xabcf123" :: Integer
180154659
Prelude> read "0o7651" :: Integer
4009
| >>> text = '100'
>>> for base in range(2,21):
print ("String '%s' in base %i is %i in base 10"
% (text, base, int(text, base)))
String '100' in base 2 is 4 in base 10
String '100' in base 3 is 9 in base 10
String '100' in base 4 is 16 in base 10
String '100' in base 5 is 25 in base 10
String '1... |
Can you help me rewrite this code in Go instead of Haskell, keeping it the same logically? | Prelude> read "123459" :: Integer
123459
Prelude> read "0xabcf123" :: Integer
180154659
Prelude> read "0o7651" :: Integer
4009
| package main
import (
"fmt"
"math/big"
"strconv"
)
func main() {
x, _ := strconv.Atoi("13")
fmt.Println(x)
x64, _ := strconv.ParseInt("3c2", 19, 64)
fmt.Println(x64)
fmt.Sscanf("1101", "%b", &x)
fmt.Println(x)
fmt.S... |
Change the programming language of this snippet from Icon to C without modifying what it does. | procedure convert (str)
write (left(str, 10) || " = " || integer(str))
end
procedure main ()
convert (" 2r1001")
convert (" 8r7135")
convert ("16rABC1234")
convert ("36r1Z")
write ("2r1001" + "36r1Z")
end
| #include <stdio.h>
int main()
{
int num;
sscanf("0123459", "%d", &num);
printf("%d\n", num);
sscanf("abcf123", "%x", &num);
printf("%d\n", num);
sscanf("7651", "%o", &num);
printf("%d\n", num);
return 0;
}
|
Write the same code in C# as shown below in Icon. | procedure convert (str)
write (left(str, 10) || " = " || integer(str))
end
procedure main ()
convert (" 2r1001")
convert (" 8r7135")
convert ("16rABC1234")
convert ("36r1Z")
write ("2r1001" + "36r1Z")
end
| using System;
class Program
{
static void Main()
{
var value = "100";
var fromBases = new[] { 2, 8, 10, 16 };
var toBase = 10;
foreach (var fromBase in fromBases)
{
Console.WriteLine("{0} in base {1} is {2} in base {3}",
value, fromBase, Conve... |
Convert this Icon block to C++, preserving its control flow and logic. | procedure convert (str)
write (left(str, 10) || " = " || integer(str))
end
procedure main ()
convert (" 2r1001")
convert (" 8r7135")
convert ("16rABC1234")
convert ("36r1Z")
write ("2r1001" + "36r1Z")
end
| #include <iostream>
#include <sstream>
int main()
{
int num;
std::istringstream("0123459") >> num;
std::cout << num << std::endl;
std::istringstream("0123459") >> std::dec >> num;
std::cout << num << std::endl;
std::istringstream("abcf123") >> std::hex >> num;
std::cout << num << std::endl;
std:... |
Port the following code from Icon to Java with equivalent syntax and logic. | procedure convert (str)
write (left(str, 10) || " = " || integer(str))
end
procedure main ()
convert (" 2r1001")
convert (" 8r7135")
convert ("16rABC1234")
convert ("36r1Z")
write ("2r1001" + "36r1Z")
end
| Scanner sc = new Scanner(System.in);
sc.useRadix(base);
sc.nextInt();
|
Translate this program into Go but keep the logic exactly as in Icon. | procedure convert (str)
write (left(str, 10) || " = " || integer(str))
end
procedure main ()
convert (" 2r1001")
convert (" 8r7135")
convert ("16rABC1234")
convert ("36r1Z")
write ("2r1001" + "36r1Z")
end
| package main
import (
"fmt"
"math/big"
"strconv"
)
func main() {
x, _ := strconv.Atoi("13")
fmt.Println(x)
x64, _ := strconv.ParseInt("3c2", 19, 64)
fmt.Println(x64)
fmt.Sscanf("1101", "%b", &x)
fmt.Println(x)
fmt.S... |
Generate an equivalent C version of this J code. | baseN=: (, 'b'&,)&.":
| #include <stdio.h>
int main()
{
int num;
sscanf("0123459", "%d", &num);
printf("%d\n", num);
sscanf("abcf123", "%x", &num);
printf("%d\n", num);
sscanf("7651", "%o", &num);
printf("%d\n", num);
return 0;
}
|
Port the provided J code into C# while preserving the original functionality. | baseN=: (, 'b'&,)&.":
| using System;
class Program
{
static void Main()
{
var value = "100";
var fromBases = new[] { 2, 8, 10, 16 };
var toBase = 10;
foreach (var fromBase in fromBases)
{
Console.WriteLine("{0} in base {1} is {2} in base {3}",
value, fromBase, Conve... |
Write a version of this J function in C++ with identical behavior. | baseN=: (, 'b'&,)&.":
| #include <iostream>
#include <sstream>
int main()
{
int num;
std::istringstream("0123459") >> num;
std::cout << num << std::endl;
std::istringstream("0123459") >> std::dec >> num;
std::cout << num << std::endl;
std::istringstream("abcf123") >> std::hex >> num;
std::cout << num << std::endl;
std:... |
Convert this J block to Java, preserving its control flow and logic. | baseN=: (, 'b'&,)&.":
| Scanner sc = new Scanner(System.in);
sc.useRadix(base);
sc.nextInt();
|
Preserve the algorithm and functionality while converting the code from J to Python. | baseN=: (, 'b'&,)&.":
| >>> text = '100'
>>> for base in range(2,21):
print ("String '%s' in base %i is %i in base 10"
% (text, base, int(text, base)))
String '100' in base 2 is 4 in base 10
String '100' in base 3 is 9 in base 10
String '100' in base 4 is 16 in base 10
String '100' in base 5 is 25 in base 10
String '1... |
Generate a Go translation of this J snippet without changing its computational steps. | baseN=: (, 'b'&,)&.":
| package main
import (
"fmt"
"math/big"
"strconv"
)
func main() {
x, _ := strconv.Atoi("13")
fmt.Println(x)
x64, _ := strconv.ParseInt("3c2", 19, 64)
fmt.Println(x64)
fmt.Sscanf("1101", "%b", &x)
fmt.Println(x)
fmt.S... |
Produce a language-to-language conversion: from Julia to C, same semantics. |
txt = "100"
for base = 2:21
base10 = parse(Int, txt, base)
println("String $txt in base $base is $base10 in base 10")
end
| #include <stdio.h>
int main()
{
int num;
sscanf("0123459", "%d", &num);
printf("%d\n", num);
sscanf("abcf123", "%x", &num);
printf("%d\n", num);
sscanf("7651", "%o", &num);
printf("%d\n", num);
return 0;
}
|
Convert the following code from Julia to C#, ensuring the logic remains intact. |
txt = "100"
for base = 2:21
base10 = parse(Int, txt, base)
println("String $txt in base $base is $base10 in base 10")
end
| using System;
class Program
{
static void Main()
{
var value = "100";
var fromBases = new[] { 2, 8, 10, 16 };
var toBase = 10;
foreach (var fromBase in fromBases)
{
Console.WriteLine("{0} in base {1} is {2} in base {3}",
value, fromBase, Conve... |
Please provide an equivalent version of this Julia code in C++. |
txt = "100"
for base = 2:21
base10 = parse(Int, txt, base)
println("String $txt in base $base is $base10 in base 10")
end
| #include <iostream>
#include <sstream>
int main()
{
int num;
std::istringstream("0123459") >> num;
std::cout << num << std::endl;
std::istringstream("0123459") >> std::dec >> num;
std::cout << num << std::endl;
std::istringstream("abcf123") >> std::hex >> num;
std::cout << num << std::endl;
std:... |
Rewrite the snippet below in Java so it works the same as the original Julia code. |
txt = "100"
for base = 2:21
base10 = parse(Int, txt, base)
println("String $txt in base $base is $base10 in base 10")
end
| Scanner sc = new Scanner(System.in);
sc.useRadix(base);
sc.nextInt();
|
Generate an equivalent Python version of this Julia code. |
txt = "100"
for base = 2:21
base10 = parse(Int, txt, base)
println("String $txt in base $base is $base10 in base 10")
end
| >>> text = '100'
>>> for base in range(2,21):
print ("String '%s' in base %i is %i in base 10"
% (text, base, int(text, base)))
String '100' in base 2 is 4 in base 10
String '100' in base 3 is 9 in base 10
String '100' in base 4 is 16 in base 10
String '100' in base 5 is 25 in base 10
String '1... |
Maintain the same structure and functionality when rewriting this code in Go. |
txt = "100"
for base = 2:21
base10 = parse(Int, txt, base)
println("String $txt in base $base is $base10 in base 10")
end
| package main
import (
"fmt"
"math/big"
"strconv"
)
func main() {
x, _ := strconv.Atoi("13")
fmt.Println(x)
x64, _ := strconv.ParseInt("3c2", 19, 64)
fmt.Println(x64)
fmt.Sscanf("1101", "%b", &x)
fmt.Println(x)
fmt.S... |
Maintain the same structure and functionality when rewriting this code in C. | print( tonumber("123") )
print( tonumber("a5b0", 16) )
print( tonumber("011101", 2) )
print( tonumber("za3r", 36) )
| #include <stdio.h>
int main()
{
int num;
sscanf("0123459", "%d", &num);
printf("%d\n", num);
sscanf("abcf123", "%x", &num);
printf("%d\n", num);
sscanf("7651", "%o", &num);
printf("%d\n", num);
return 0;
}
|
Change the following Lua code into C# without altering its purpose. | print( tonumber("123") )
print( tonumber("a5b0", 16) )
print( tonumber("011101", 2) )
print( tonumber("za3r", 36) )
| using System;
class Program
{
static void Main()
{
var value = "100";
var fromBases = new[] { 2, 8, 10, 16 };
var toBase = 10;
foreach (var fromBase in fromBases)
{
Console.WriteLine("{0} in base {1} is {2} in base {3}",
value, fromBase, Conve... |
Produce a functionally identical C++ code for the snippet given in Lua. | print( tonumber("123") )
print( tonumber("a5b0", 16) )
print( tonumber("011101", 2) )
print( tonumber("za3r", 36) )
| #include <iostream>
#include <sstream>
int main()
{
int num;
std::istringstream("0123459") >> num;
std::cout << num << std::endl;
std::istringstream("0123459") >> std::dec >> num;
std::cout << num << std::endl;
std::istringstream("abcf123") >> std::hex >> num;
std::cout << num << std::endl;
std:... |
Transform the following Lua implementation into Java, maintaining the same output and logic. | print( tonumber("123") )
print( tonumber("a5b0", 16) )
print( tonumber("011101", 2) )
print( tonumber("za3r", 36) )
| Scanner sc = new Scanner(System.in);
sc.useRadix(base);
sc.nextInt();
|
Change the programming language of this snippet from Lua to Python without modifying what it does. | print( tonumber("123") )
print( tonumber("a5b0", 16) )
print( tonumber("011101", 2) )
print( tonumber("za3r", 36) )
| >>> text = '100'
>>> for base in range(2,21):
print ("String '%s' in base %i is %i in base 10"
% (text, base, int(text, base)))
String '100' in base 2 is 4 in base 10
String '100' in base 3 is 9 in base 10
String '100' in base 4 is 16 in base 10
String '100' in base 5 is 25 in base 10
String '1... |
Preserve the algorithm and functionality while converting the code from Lua to Go. | print( tonumber("123") )
print( tonumber("a5b0", 16) )
print( tonumber("011101", 2) )
print( tonumber("za3r", 36) )
| package main
import (
"fmt"
"math/big"
"strconv"
)
func main() {
x, _ := strconv.Atoi("13")
fmt.Println(x)
x64, _ := strconv.ParseInt("3c2", 19, 64)
fmt.Println(x64)
fmt.Sscanf("1101", "%b", &x)
fmt.Println(x)
fmt.S... |
Change the following Mathematica code into C without altering its purpose. | 19^^91g5dcg2h6da7260a9f3c4a
2^^11110001001000000
| #include <stdio.h>
int main()
{
int num;
sscanf("0123459", "%d", &num);
printf("%d\n", num);
sscanf("abcf123", "%x", &num);
printf("%d\n", num);
sscanf("7651", "%o", &num);
printf("%d\n", num);
return 0;
}
|
Convert the following code from Mathematica to C#, ensuring the logic remains intact. | 19^^91g5dcg2h6da7260a9f3c4a
2^^11110001001000000
| using System;
class Program
{
static void Main()
{
var value = "100";
var fromBases = new[] { 2, 8, 10, 16 };
var toBase = 10;
foreach (var fromBase in fromBases)
{
Console.WriteLine("{0} in base {1} is {2} in base {3}",
value, fromBase, Conve... |
Preserve the algorithm and functionality while converting the code from Mathematica to C++. | 19^^91g5dcg2h6da7260a9f3c4a
2^^11110001001000000
| #include <iostream>
#include <sstream>
int main()
{
int num;
std::istringstream("0123459") >> num;
std::cout << num << std::endl;
std::istringstream("0123459") >> std::dec >> num;
std::cout << num << std::endl;
std::istringstream("abcf123") >> std::hex >> num;
std::cout << num << std::endl;
std:... |
Convert the following code from Mathematica to Java, ensuring the logic remains intact. | 19^^91g5dcg2h6da7260a9f3c4a
2^^11110001001000000
| Scanner sc = new Scanner(System.in);
sc.useRadix(base);
sc.nextInt();
|
Write the same algorithm in Python as shown in this Mathematica implementation. | 19^^91g5dcg2h6da7260a9f3c4a
2^^11110001001000000
| >>> text = '100'
>>> for base in range(2,21):
print ("String '%s' in base %i is %i in base 10"
% (text, base, int(text, base)))
String '100' in base 2 is 4 in base 10
String '100' in base 3 is 9 in base 10
String '100' in base 4 is 16 in base 10
String '100' in base 5 is 25 in base 10
String '1... |
Write the same algorithm in Go as shown in this Mathematica implementation. | 19^^91g5dcg2h6da7260a9f3c4a
2^^11110001001000000
| package main
import (
"fmt"
"math/big"
"strconv"
)
func main() {
x, _ := strconv.Atoi("13")
fmt.Println(x)
x64, _ := strconv.ParseInt("3c2", 19, 64)
fmt.Println(x64)
fmt.Sscanf("1101", "%b", &x)
fmt.Println(x)
fmt.S... |
Please provide an equivalent version of this MATLAB code in C. | val = sscanf('11 11 11','
| #include <stdio.h>
int main()
{
int num;
sscanf("0123459", "%d", &num);
printf("%d\n", num);
sscanf("abcf123", "%x", &num);
printf("%d\n", num);
sscanf("7651", "%o", &num);
printf("%d\n", num);
return 0;
}
|
Produce a functionally identical C# code for the snippet given in MATLAB. | val = sscanf('11 11 11','
| using System;
class Program
{
static void Main()
{
var value = "100";
var fromBases = new[] { 2, 8, 10, 16 };
var toBase = 10;
foreach (var fromBase in fromBases)
{
Console.WriteLine("{0} in base {1} is {2} in base {3}",
value, fromBase, Conve... |
Convert the following code from MATLAB to C++, ensuring the logic remains intact. | val = sscanf('11 11 11','
| #include <iostream>
#include <sstream>
int main()
{
int num;
std::istringstream("0123459") >> num;
std::cout << num << std::endl;
std::istringstream("0123459") >> std::dec >> num;
std::cout << num << std::endl;
std::istringstream("abcf123") >> std::hex >> num;
std::cout << num << std::endl;
std:... |
Convert the following code from MATLAB to Java, ensuring the logic remains intact. | val = sscanf('11 11 11','
| Scanner sc = new Scanner(System.in);
sc.useRadix(base);
sc.nextInt();
|
Change the following MATLAB code into Python without altering its purpose. | val = sscanf('11 11 11','
| >>> text = '100'
>>> for base in range(2,21):
print ("String '%s' in base %i is %i in base 10"
% (text, base, int(text, base)))
String '100' in base 2 is 4 in base 10
String '100' in base 3 is 9 in base 10
String '100' in base 4 is 16 in base 10
String '100' in base 5 is 25 in base 10
String '1... |
Convert this MATLAB snippet to Go and keep its semantics consistent. | val = sscanf('11 11 11','
| package main
import (
"fmt"
"math/big"
"strconv"
)
func main() {
x, _ := strconv.Atoi("13")
fmt.Println(x)
x64, _ := strconv.ParseInt("3c2", 19, 64)
fmt.Println(x64)
fmt.Sscanf("1101", "%b", &x)
fmt.Println(x)
fmt.S... |
Port the provided Nim code into C while preserving the original functionality. | import strutils
echo parseInt "10"
echo parseHexInt "0x10"
echo parseHexInt "10"
echo parseOctInt "0o120"
echo parseOctInt "120"
| #include <stdio.h>
int main()
{
int num;
sscanf("0123459", "%d", &num);
printf("%d\n", num);
sscanf("abcf123", "%x", &num);
printf("%d\n", num);
sscanf("7651", "%o", &num);
printf("%d\n", num);
return 0;
}
|
Please provide an equivalent version of this Nim code in C#. | import strutils
echo parseInt "10"
echo parseHexInt "0x10"
echo parseHexInt "10"
echo parseOctInt "0o120"
echo parseOctInt "120"
| using System;
class Program
{
static void Main()
{
var value = "100";
var fromBases = new[] { 2, 8, 10, 16 };
var toBase = 10;
foreach (var fromBase in fromBases)
{
Console.WriteLine("{0} in base {1} is {2} in base {3}",
value, fromBase, Conve... |
Preserve the algorithm and functionality while converting the code from Nim to C++. | import strutils
echo parseInt "10"
echo parseHexInt "0x10"
echo parseHexInt "10"
echo parseOctInt "0o120"
echo parseOctInt "120"
| #include <iostream>
#include <sstream>
int main()
{
int num;
std::istringstream("0123459") >> num;
std::cout << num << std::endl;
std::istringstream("0123459") >> std::dec >> num;
std::cout << num << std::endl;
std::istringstream("abcf123") >> std::hex >> num;
std::cout << num << std::endl;
std:... |
Translate the given Nim code snippet into Python without altering its behavior. | import strutils
echo parseInt "10"
echo parseHexInt "0x10"
echo parseHexInt "10"
echo parseOctInt "0o120"
echo parseOctInt "120"
| >>> text = '100'
>>> for base in range(2,21):
print ("String '%s' in base %i is %i in base 10"
% (text, base, int(text, base)))
String '100' in base 2 is 4 in base 10
String '100' in base 3 is 9 in base 10
String '100' in base 4 is 16 in base 10
String '100' in base 5 is 25 in base 10
String '1... |
Translate the given Nim code snippet into Go without altering its behavior. | import strutils
echo parseInt "10"
echo parseHexInt "0x10"
echo parseHexInt "10"
echo parseOctInt "0o120"
echo parseOctInt "120"
| package main
import (
"fmt"
"math/big"
"strconv"
)
func main() {
x, _ := strconv.Atoi("13")
fmt.Println(x)
x64, _ := strconv.ParseInt("3c2", 19, 64)
fmt.Println(x64)
fmt.Sscanf("1101", "%b", &x)
fmt.Println(x)
fmt.S... |
Rewrite the snippet below in C so it works the same as the original OCaml code. | # int_of_string "123459";;
- : int = 123459
# int_of_string "0xabcf123";;
- : int = 180154659
# int_of_string "0o7651";;
- : int = 4009
# int_of_string "0b101011001";;
- : int = 345
| #include <stdio.h>
int main()
{
int num;
sscanf("0123459", "%d", &num);
printf("%d\n", num);
sscanf("abcf123", "%x", &num);
printf("%d\n", num);
sscanf("7651", "%o", &num);
printf("%d\n", num);
return 0;
}
|
Can you help me rewrite this code in C# instead of OCaml, keeping it the same logically? | # int_of_string "123459";;
- : int = 123459
# int_of_string "0xabcf123";;
- : int = 180154659
# int_of_string "0o7651";;
- : int = 4009
# int_of_string "0b101011001";;
- : int = 345
| using System;
class Program
{
static void Main()
{
var value = "100";
var fromBases = new[] { 2, 8, 10, 16 };
var toBase = 10;
foreach (var fromBase in fromBases)
{
Console.WriteLine("{0} in base {1} is {2} in base {3}",
value, fromBase, Conve... |
Port the provided OCaml code into C++ while preserving the original functionality. | # int_of_string "123459";;
- : int = 123459
# int_of_string "0xabcf123";;
- : int = 180154659
# int_of_string "0o7651";;
- : int = 4009
# int_of_string "0b101011001";;
- : int = 345
| #include <iostream>
#include <sstream>
int main()
{
int num;
std::istringstream("0123459") >> num;
std::cout << num << std::endl;
std::istringstream("0123459") >> std::dec >> num;
std::cout << num << std::endl;
std::istringstream("abcf123") >> std::hex >> num;
std::cout << num << std::endl;
std:... |
Write the same algorithm in Java as shown in this OCaml implementation. | # int_of_string "123459";;
- : int = 123459
# int_of_string "0xabcf123";;
- : int = 180154659
# int_of_string "0o7651";;
- : int = 4009
# int_of_string "0b101011001";;
- : int = 345
| Scanner sc = new Scanner(System.in);
sc.useRadix(base);
sc.nextInt();
|
Produce a language-to-language conversion: from OCaml to Python, same semantics. | # int_of_string "123459";;
- : int = 123459
# int_of_string "0xabcf123";;
- : int = 180154659
# int_of_string "0o7651";;
- : int = 4009
# int_of_string "0b101011001";;
- : int = 345
| >>> text = '100'
>>> for base in range(2,21):
print ("String '%s' in base %i is %i in base 10"
% (text, base, int(text, base)))
String '100' in base 2 is 4 in base 10
String '100' in base 3 is 9 in base 10
String '100' in base 4 is 16 in base 10
String '100' in base 5 is 25 in base 10
String '1... |
Produce a language-to-language conversion: from OCaml to Go, same semantics. | # int_of_string "123459";;
- : int = 123459
# int_of_string "0xabcf123";;
- : int = 180154659
# int_of_string "0o7651";;
- : int = 4009
# int_of_string "0b101011001";;
- : int = 345
| package main
import (
"fmt"
"math/big"
"strconv"
)
func main() {
x, _ := strconv.Atoi("13")
fmt.Println(x)
x64, _ := strconv.ParseInt("3c2", 19, 64)
fmt.Println(x64)
fmt.Sscanf("1101", "%b", &x)
fmt.Println(x)
fmt.S... |
Generate an equivalent C version of this Pascal code. | program readIntegers(input, output);
var
i: aluSInt;
begin
while not EOF(input) do
begin
readLn(i);
writeLn(i:24);
end;
end.
| #include <stdio.h>
int main()
{
int num;
sscanf("0123459", "%d", &num);
printf("%d\n", num);
sscanf("abcf123", "%x", &num);
printf("%d\n", num);
sscanf("7651", "%o", &num);
printf("%d\n", num);
return 0;
}
|
Port the following code from Pascal to C# with equivalent syntax and logic. | program readIntegers(input, output);
var
i: aluSInt;
begin
while not EOF(input) do
begin
readLn(i);
writeLn(i:24);
end;
end.
| using System;
class Program
{
static void Main()
{
var value = "100";
var fromBases = new[] { 2, 8, 10, 16 };
var toBase = 10;
foreach (var fromBase in fromBases)
{
Console.WriteLine("{0} in base {1} is {2} in base {3}",
value, fromBase, Conve... |
Convert this Pascal block to C++, preserving its control flow and logic. | program readIntegers(input, output);
var
i: aluSInt;
begin
while not EOF(input) do
begin
readLn(i);
writeLn(i:24);
end;
end.
| #include <iostream>
#include <sstream>
int main()
{
int num;
std::istringstream("0123459") >> num;
std::cout << num << std::endl;
std::istringstream("0123459") >> std::dec >> num;
std::cout << num << std::endl;
std::istringstream("abcf123") >> std::hex >> num;
std::cout << num << std::endl;
std:... |
Keep all operations the same but rewrite the snippet in Java. | program readIntegers(input, output);
var
i: aluSInt;
begin
while not EOF(input) do
begin
readLn(i);
writeLn(i:24);
end;
end.
| Scanner sc = new Scanner(System.in);
sc.useRadix(base);
sc.nextInt();
|
Produce a functionally identical Python code for the snippet given in Pascal. | program readIntegers(input, output);
var
i: aluSInt;
begin
while not EOF(input) do
begin
readLn(i);
writeLn(i:24);
end;
end.
| >>> text = '100'
>>> for base in range(2,21):
print ("String '%s' in base %i is %i in base 10"
% (text, base, int(text, base)))
String '100' in base 2 is 4 in base 10
String '100' in base 3 is 9 in base 10
String '100' in base 4 is 16 in base 10
String '100' in base 5 is 25 in base 10
String '1... |
Please provide an equivalent version of this Pascal code in Go. | program readIntegers(input, output);
var
i: aluSInt;
begin
while not EOF(input) do
begin
readLn(i);
writeLn(i:24);
end;
end.
| package main
import (
"fmt"
"math/big"
"strconv"
)
func main() {
x, _ := strconv.Atoi("13")
fmt.Println(x)
x64, _ := strconv.ParseInt("3c2", 19, 64)
fmt.Println(x64)
fmt.Sscanf("1101", "%b", &x)
fmt.Println(x)
fmt.S... |
Generate an equivalent C version of this Perl code. | my $dec = "0123459";
my $hex_noprefix = "abcf123";
my $hex_withprefix = "0xabcf123";
my $oct_noprefix = "7651";
my $oct_withprefix = "07651";
my $bin_withprefix = "0b101011001";
print 0 + $dec, "\n";
print hex($hex_noprefix), "\n";
print hex($hex_withprefix), "\n";
print oct($hex_withprefix), "\n";
prin... | #include <stdio.h>
int main()
{
int num;
sscanf("0123459", "%d", &num);
printf("%d\n", num);
sscanf("abcf123", "%x", &num);
printf("%d\n", num);
sscanf("7651", "%o", &num);
printf("%d\n", num);
return 0;
}
|
Generate a C# translation of this Perl snippet without changing its computational steps. | my $dec = "0123459";
my $hex_noprefix = "abcf123";
my $hex_withprefix = "0xabcf123";
my $oct_noprefix = "7651";
my $oct_withprefix = "07651";
my $bin_withprefix = "0b101011001";
print 0 + $dec, "\n";
print hex($hex_noprefix), "\n";
print hex($hex_withprefix), "\n";
print oct($hex_withprefix), "\n";
prin... | using System;
class Program
{
static void Main()
{
var value = "100";
var fromBases = new[] { 2, 8, 10, 16 };
var toBase = 10;
foreach (var fromBase in fromBases)
{
Console.WriteLine("{0} in base {1} is {2} in base {3}",
value, fromBase, Conve... |
Transform the following Perl implementation into C++, maintaining the same output and logic. | my $dec = "0123459";
my $hex_noprefix = "abcf123";
my $hex_withprefix = "0xabcf123";
my $oct_noprefix = "7651";
my $oct_withprefix = "07651";
my $bin_withprefix = "0b101011001";
print 0 + $dec, "\n";
print hex($hex_noprefix), "\n";
print hex($hex_withprefix), "\n";
print oct($hex_withprefix), "\n";
prin... | #include <iostream>
#include <sstream>
int main()
{
int num;
std::istringstream("0123459") >> num;
std::cout << num << std::endl;
std::istringstream("0123459") >> std::dec >> num;
std::cout << num << std::endl;
std::istringstream("abcf123") >> std::hex >> num;
std::cout << num << std::endl;
std:... |
Write the same code in Java as shown below in Perl. | my $dec = "0123459";
my $hex_noprefix = "abcf123";
my $hex_withprefix = "0xabcf123";
my $oct_noprefix = "7651";
my $oct_withprefix = "07651";
my $bin_withprefix = "0b101011001";
print 0 + $dec, "\n";
print hex($hex_noprefix), "\n";
print hex($hex_withprefix), "\n";
print oct($hex_withprefix), "\n";
prin... | Scanner sc = new Scanner(System.in);
sc.useRadix(base);
sc.nextInt();
|
Convert this Perl block to Python, preserving its control flow and logic. | my $dec = "0123459";
my $hex_noprefix = "abcf123";
my $hex_withprefix = "0xabcf123";
my $oct_noprefix = "7651";
my $oct_withprefix = "07651";
my $bin_withprefix = "0b101011001";
print 0 + $dec, "\n";
print hex($hex_noprefix), "\n";
print hex($hex_withprefix), "\n";
print oct($hex_withprefix), "\n";
prin... | >>> text = '100'
>>> for base in range(2,21):
print ("String '%s' in base %i is %i in base 10"
% (text, base, int(text, base)))
String '100' in base 2 is 4 in base 10
String '100' in base 3 is 9 in base 10
String '100' in base 4 is 16 in base 10
String '100' in base 5 is 25 in base 10
String '1... |
Convert the following code from Perl to Go, ensuring the logic remains intact. | my $dec = "0123459";
my $hex_noprefix = "abcf123";
my $hex_withprefix = "0xabcf123";
my $oct_noprefix = "7651";
my $oct_withprefix = "07651";
my $bin_withprefix = "0b101011001";
print 0 + $dec, "\n";
print hex($hex_noprefix), "\n";
print hex($hex_withprefix), "\n";
print oct($hex_withprefix), "\n";
prin... | package main
import (
"fmt"
"math/big"
"strconv"
)
func main() {
x, _ := strconv.Atoi("13")
fmt.Println(x)
x64, _ := strconv.ParseInt("3c2", 19, 64)
fmt.Println(x64)
fmt.Sscanf("1101", "%b", &x)
fmt.Println(x)
fmt.S... |
Translate the given PowerShell code snippet into C without altering its behavior. | function Select-NumberFromString
{
[CmdletBinding(DefaultParameterSetName="Decimal")]
[OutputType([PSCustomObject])]
Param
(
[Parameter(Mandatory=$true,
ValueFromPipeline=$true,
ValueFromPipelineByPropertyName=$true,
Position=0)]
[... | #include <stdio.h>
int main()
{
int num;
sscanf("0123459", "%d", &num);
printf("%d\n", num);
sscanf("abcf123", "%x", &num);
printf("%d\n", num);
sscanf("7651", "%o", &num);
printf("%d\n", num);
return 0;
}
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.