Instruction stringlengths 45 106 | input_code stringlengths 1 13.7k | output_code stringlengths 1 13.7k |
|---|---|---|
Write a version of this Ruby function in C with identical behavior. | puts "You entered:
begin
puts "You entered:
rescue ex
puts ex
end
| #include <stdio.h>
#include <stdlib.h>
int main(void)
{
char str[BUFSIZ];
puts("Enter a string: ");
fgets(str, sizeof(str), stdin);
long num;
char buf[BUFSIZ];
do
{
puts("Enter 75000: ");
fgets(buf, sizeof(buf), stdin);
num = strtol(buf, NULL, 10);
} w... |
Convert this Ruby snippet to C# and keep its semantics consistent. | puts "You entered:
begin
puts "You entered:
rescue ex
puts ex
end
| using System;
namespace C_Sharp_Console {
class example {
static void Main() {
string word;
int num;
Console.Write("Enter an integer: ");
num = Console.Read();
Console.Write("Enter a String: ");
word = Console.ReadLine()... |
Rewrite this program in C++ while keeping its functionality equivalent to the Ruby version. | puts "You entered:
begin
puts "You entered:
rescue ex
puts ex
end
| #include <iostream>
#include <string>
using namespace std;
int main()
{
long int integer_input;
string string_input;
cout << "Enter an integer: ";
cin >> integer_input;
cout << "Enter a string: ";
cin >> string_input;
return 0;
}
|
Keep all operations the same but rewrite the snippet in Java. | puts "You entered:
begin
puts "You entered:
rescue ex
puts ex
end
| import java.util.Scanner;
public class GetInput {
public static void main(String[] args) throws Exception {
Scanner s = new Scanner(System.in);
System.out.print("Enter a string: ");
String str = s.nextLine();
System.out.print("Enter an integer: ");
int i = Integer.parseInt(s... |
Change the following Ruby code into Python without altering its purpose. | puts "You entered:
begin
puts "You entered:
rescue ex
puts ex
end
| string = raw_input("Input a string: ")
|
Change the programming language of this snippet from Ruby to VB without modifying what it does. | puts "You entered:
begin
puts "You entered:
rescue ex
puts ex
end
| Public Sub text()
Debug.Print InputBox("Input a string")
Debug.Print InputBox("Input the integer 75000", "Input an integer", 75000, Context = "Long")
End Sub
|
Keep all operations the same but rewrite the snippet in Go. | puts "You entered:
begin
puts "You entered:
rescue ex
puts ex
end
| package main
import "fmt"
func main() {
var s string
var i int
if _, err := fmt.Scan(&s, &i); err == nil && i == 75000 {
fmt.Println("good")
} else {
fmt.Println("wrong")
}
}
|
Rewrite the snippet below in C so it works the same as the original Scala code. |
fun main(args: Array<String>) {
print("Enter a string : ")
val s = readLine()!!
println(s)
do {
print("Enter 75000 : ")
val number = readLine()!!.toInt()
} while (number != 75000)
}
| #include <stdio.h>
#include <stdlib.h>
int main(void)
{
char str[BUFSIZ];
puts("Enter a string: ");
fgets(str, sizeof(str), stdin);
long num;
char buf[BUFSIZ];
do
{
puts("Enter 75000: ");
fgets(buf, sizeof(buf), stdin);
num = strtol(buf, NULL, 10);
} w... |
Can you help me rewrite this code in C# instead of Scala, keeping it the same logically? |
fun main(args: Array<String>) {
print("Enter a string : ")
val s = readLine()!!
println(s)
do {
print("Enter 75000 : ")
val number = readLine()!!.toInt()
} while (number != 75000)
}
| using System;
namespace C_Sharp_Console {
class example {
static void Main() {
string word;
int num;
Console.Write("Enter an integer: ");
num = Console.Read();
Console.Write("Enter a String: ");
word = Console.ReadLine()... |
Can you help me rewrite this code in C++ instead of Scala, keeping it the same logically? |
fun main(args: Array<String>) {
print("Enter a string : ")
val s = readLine()!!
println(s)
do {
print("Enter 75000 : ")
val number = readLine()!!.toInt()
} while (number != 75000)
}
| #include <iostream>
#include <string>
using namespace std;
int main()
{
long int integer_input;
string string_input;
cout << "Enter an integer: ";
cin >> integer_input;
cout << "Enter a string: ";
cin >> string_input;
return 0;
}
|
Maintain the same structure and functionality when rewriting this code in Java. |
fun main(args: Array<String>) {
print("Enter a string : ")
val s = readLine()!!
println(s)
do {
print("Enter 75000 : ")
val number = readLine()!!.toInt()
} while (number != 75000)
}
| import java.util.Scanner;
public class GetInput {
public static void main(String[] args) throws Exception {
Scanner s = new Scanner(System.in);
System.out.print("Enter a string: ");
String str = s.nextLine();
System.out.print("Enter an integer: ");
int i = Integer.parseInt(s... |
Please provide an equivalent version of this Scala code in Python. |
fun main(args: Array<String>) {
print("Enter a string : ")
val s = readLine()!!
println(s)
do {
print("Enter 75000 : ")
val number = readLine()!!.toInt()
} while (number != 75000)
}
| string = raw_input("Input a string: ")
|
Produce a functionally identical VB code for the snippet given in Scala. |
fun main(args: Array<String>) {
print("Enter a string : ")
val s = readLine()!!
println(s)
do {
print("Enter 75000 : ")
val number = readLine()!!.toInt()
} while (number != 75000)
}
| Public Sub text()
Debug.Print InputBox("Input a string")
Debug.Print InputBox("Input the integer 75000", "Input an integer", 75000, Context = "Long")
End Sub
|
Preserve the algorithm and functionality while converting the code from Scala to Go. |
fun main(args: Array<String>) {
print("Enter a string : ")
val s = readLine()!!
println(s)
do {
print("Enter 75000 : ")
val number = readLine()!!.toInt()
} while (number != 75000)
}
| package main
import "fmt"
func main() {
var s string
var i int
if _, err := fmt.Scan(&s, &i); err == nil && i == 75000 {
fmt.Println("good")
} else {
fmt.Println("wrong")
}
}
|
Produce a functionally identical C code for the snippet given in Swift. | print("Enter a string: ", terminator: "")
if let str = readLine() {
print(str)
}
| #include <stdio.h>
#include <stdlib.h>
int main(void)
{
char str[BUFSIZ];
puts("Enter a string: ");
fgets(str, sizeof(str), stdin);
long num;
char buf[BUFSIZ];
do
{
puts("Enter 75000: ");
fgets(buf, sizeof(buf), stdin);
num = strtol(buf, NULL, 10);
} w... |
Rewrite this program in C# while keeping its functionality equivalent to the Swift version. | print("Enter a string: ", terminator: "")
if let str = readLine() {
print(str)
}
| using System;
namespace C_Sharp_Console {
class example {
static void Main() {
string word;
int num;
Console.Write("Enter an integer: ");
num = Console.Read();
Console.Write("Enter a String: ");
word = Console.ReadLine()... |
Write a version of this Swift function in C++ with identical behavior. | print("Enter a string: ", terminator: "")
if let str = readLine() {
print(str)
}
| #include <iostream>
#include <string>
using namespace std;
int main()
{
long int integer_input;
string string_input;
cout << "Enter an integer: ";
cin >> integer_input;
cout << "Enter a string: ";
cin >> string_input;
return 0;
}
|
Generate an equivalent Java version of this Swift code. | print("Enter a string: ", terminator: "")
if let str = readLine() {
print(str)
}
| import java.util.Scanner;
public class GetInput {
public static void main(String[] args) throws Exception {
Scanner s = new Scanner(System.in);
System.out.print("Enter a string: ");
String str = s.nextLine();
System.out.print("Enter an integer: ");
int i = Integer.parseInt(s... |
Translate this program into Python but keep the logic exactly as in Swift. | print("Enter a string: ", terminator: "")
if let str = readLine() {
print(str)
}
| string = raw_input("Input a string: ")
|
Write the same algorithm in VB as shown in this Swift implementation. | print("Enter a string: ", terminator: "")
if let str = readLine() {
print(str)
}
| Public Sub text()
Debug.Print InputBox("Input a string")
Debug.Print InputBox("Input the integer 75000", "Input an integer", 75000, Context = "Long")
End Sub
|
Change the following Swift code into Go without altering its purpose. | print("Enter a string: ", terminator: "")
if let str = readLine() {
print(str)
}
| package main
import "fmt"
func main() {
var s string
var i int
if _, err := fmt.Scan(&s, &i); err == nil && i == 75000 {
fmt.Println("good")
} else {
fmt.Println("wrong")
}
}
|
Generate a C translation of this Tcl snippet without changing its computational steps. |
write "Enter a string: "
set text [readline]
set num 0
while {[canread] && $num != 75000} {
write "Enter the number 75000: "
set num [readline]
}
print $text
print $num
| #include <stdio.h>
#include <stdlib.h>
int main(void)
{
char str[BUFSIZ];
puts("Enter a string: ");
fgets(str, sizeof(str), stdin);
long num;
char buf[BUFSIZ];
do
{
puts("Enter 75000: ");
fgets(buf, sizeof(buf), stdin);
num = strtol(buf, NULL, 10);
} w... |
Can you help me rewrite this code in C# instead of Tcl, keeping it the same logically? |
write "Enter a string: "
set text [readline]
set num 0
while {[canread] && $num != 75000} {
write "Enter the number 75000: "
set num [readline]
}
print $text
print $num
| using System;
namespace C_Sharp_Console {
class example {
static void Main() {
string word;
int num;
Console.Write("Enter an integer: ");
num = Console.Read();
Console.Write("Enter a String: ");
word = Console.ReadLine()... |
Produce a functionally identical C++ code for the snippet given in Tcl. |
write "Enter a string: "
set text [readline]
set num 0
while {[canread] && $num != 75000} {
write "Enter the number 75000: "
set num [readline]
}
print $text
print $num
| #include <iostream>
#include <string>
using namespace std;
int main()
{
long int integer_input;
string string_input;
cout << "Enter an integer: ";
cin >> integer_input;
cout << "Enter a string: ";
cin >> string_input;
return 0;
}
|
Port the following code from Tcl to Java with equivalent syntax and logic. |
write "Enter a string: "
set text [readline]
set num 0
while {[canread] && $num != 75000} {
write "Enter the number 75000: "
set num [readline]
}
print $text
print $num
| import java.util.Scanner;
public class GetInput {
public static void main(String[] args) throws Exception {
Scanner s = new Scanner(System.in);
System.out.print("Enter a string: ");
String str = s.nextLine();
System.out.print("Enter an integer: ");
int i = Integer.parseInt(s... |
Can you help me rewrite this code in Python instead of Tcl, keeping it the same logically? |
write "Enter a string: "
set text [readline]
set num 0
while {[canread] && $num != 75000} {
write "Enter the number 75000: "
set num [readline]
}
print $text
print $num
| string = raw_input("Input a string: ")
|
Produce a functionally identical VB code for the snippet given in Tcl. |
write "Enter a string: "
set text [readline]
set num 0
while {[canread] && $num != 75000} {
write "Enter the number 75000: "
set num [readline]
}
print $text
print $num
| Public Sub text()
Debug.Print InputBox("Input a string")
Debug.Print InputBox("Input the integer 75000", "Input an integer", 75000, Context = "Long")
End Sub
|
Keep all operations the same but rewrite the snippet in Go. |
write "Enter a string: "
set text [readline]
set num 0
while {[canread] && $num != 75000} {
write "Enter the number 75000: "
set num [readline]
}
print $text
print $num
| package main
import "fmt"
func main() {
var s string
var i int
if _, err := fmt.Scan(&s, &i); err == nil && i == 75000 {
fmt.Println("good")
} else {
fmt.Println("wrong")
}
}
|
Generate a PHP translation of this Rust snippet without changing its computational steps. | use std::io::{self, Write};
use std::fmt::Display;
use std::process;
fn main() {
let s = grab_input("Give me a string")
.unwrap_or_else(|e| exit_err(&e, e.raw_os_error().unwrap_or(-1)));
println!("You entered: {}", s.trim());
let n: i32 = grab_input("Give me an integer")
.unwrap_or_else(|... | #!/usr/bin/php
<?php
$string = fgets(STDIN);
$integer = (int) fgets(STDIN);
|
Write the same algorithm in PHP as shown in this Ada implementation. | function Get_String return String is
Line : String (1 .. 1_000);
Last : Natural;
begin
Get_Line (Line, Last);
return Line (1 .. Last);
end Get_String;
function Get_Integer return Integer is
S : constant String := Get_String;
begin
return Integer'Value (S);
end Get_Integer;
| #!/usr/bin/php
<?php
$string = fgets(STDIN);
$integer = (int) fgets(STDIN);
|
Change the following Arturo code into PHP without altering its purpose. | str: input "Enter a string: "
num: to :integer input "Enter an integer: "
print ["Got:" str "," num]
| #!/usr/bin/php
<?php
$string = fgets(STDIN);
$integer = (int) fgets(STDIN);
|
Keep all operations the same but rewrite the snippet in PHP. | DllCall("AllocConsole")
FileAppend, please type something`n, CONOUT$
FileReadLine, line, CONIN$, 1
msgbox % line
FileAppend, please type '75000'`n, CONOUT$
FileReadLine, line, CONIN$, 1
msgbox % line
| #!/usr/bin/php
<?php
$string = fgets(STDIN);
$integer = (int) fgets(STDIN);
|
Generate a PHP translation of this AWK snippet without changing its computational steps. | ~/src/opt/run $ awk 'BEGIN{printf "enter a string: "}{s=$0;i=$0+0;print "ok,"s"/"i}'
enter a string: hello world
ok,hello world/0
75000
ok,75000/75000
| #!/usr/bin/php
<?php
$string = fgets(STDIN);
$integer = (int) fgets(STDIN);
|
Produce a functionally identical PHP code for the snippet given in BBC_Basic. | INPUT LINE "Enter a string: " string$
INPUT "Enter a number: " number
PRINT "String = """ string$ """"
PRINT "Number = " ; number
| #!/usr/bin/php
<?php
$string = fgets(STDIN);
$integer = (int) fgets(STDIN);
|
Change the programming language of this snippet from Common_Lisp to PHP without modifying what it does. | (import '(java.util Scanner))
(def scan (Scanner. *in*))
(def s (.nextLine scan))
(def n (.nextInt scan))
| #!/usr/bin/php
<?php
$string = fgets(STDIN);
$integer = (int) fgets(STDIN);
|
Please provide an equivalent version of this D code in PHP. | import std.stdio;
void main() {
long number;
write("Enter an integer: ");
readf("%d", &number);
char[] str;
write("Enter a string: ");
readf(" %s\n", &str);
writeln("Read in '", number, "' and '", str, "'");
}
| #!/usr/bin/php
<?php
$string = fgets(STDIN);
$integer = (int) fgets(STDIN);
|
Convert the following code from Delphi to PHP, ensuring the logic remains intact. | program UserInputText;
uses SysUtils;
var
s: string;
lStringValue: string;
lIntegerValue: Integer;
begin
WriteLn('Enter a string:');
Readln(lStringValue);
repeat
WriteLn('Enter the number 75000');
Readln(s);
lIntegerValue := StrToIntDef(s, 0);
if lIntegerValue <> 75000 then
Writel... | #!/usr/bin/php
<?php
$string = fgets(STDIN);
$integer = (int) fgets(STDIN);
|
Write the same code in PHP as shown below in Elixir. | a = IO.gets("Enter a string: ") |> String.strip
b = IO.gets("Enter an integer: ") |> String.strip |> String.to_integer
f = IO.gets("Enter a real number: ") |> String.strip |> String.to_float
IO.puts "String =
IO.puts "Integer =
IO.puts "Float =
| #!/usr/bin/php
<?php
$string = fgets(STDIN);
$integer = (int) fgets(STDIN);
|
Write a version of this Erlang function in PHP with identical behavior. | {ok, [String]} = io:fread("Enter a string: ","~s").
{ok, [Number]} = io:fread("Enter a number: ","~d").
| #!/usr/bin/php
<?php
$string = fgets(STDIN);
$integer = (int) fgets(STDIN);
|
Port the following code from F# to PHP with equivalent syntax and logic. | open System
let ask_for_input s =
printf "%s (End with Return): " s
Console.ReadLine()
[<EntryPoint>]
let main argv =
ask_for_input "Input a string" |> ignore
ask_for_input "Enter the number 75000" |> ignore
0
| #!/usr/bin/php
<?php
$string = fgets(STDIN);
$integer = (int) fgets(STDIN);
|
Can you help me rewrite this code in PHP instead of Factor, keeping it the same logically? | "Enter a string: " write
readln
"Enter a number: " write
readln string>number
| #!/usr/bin/php
<?php
$string = fgets(STDIN);
$integer = (int) fgets(STDIN);
|
Write the same code in PHP as shown below in Forth. | : INPUT$
PAD SWAP ACCEPT
PAD SWAP ;
| #!/usr/bin/php
<?php
$string = fgets(STDIN);
$integer = (int) fgets(STDIN);
|
Transform the following Fortran implementation into PHP, maintaining the same output and logic. | character(20) :: s
integer :: i
print*, "Enter a string (max 20 characters)"
read*, s
print*, "Enter the integer 75000"
read*, i
| #!/usr/bin/php
<?php
$string = fgets(STDIN);
$integer = (int) fgets(STDIN);
|
Produce a functionally identical PHP code for the snippet given in Groovy. | word = System.in.readLine()
num = System.in.readLine().toInteger()
| #!/usr/bin/php
<?php
$string = fgets(STDIN);
$integer = (int) fgets(STDIN);
|
Translate the given Haskell code snippet into PHP without altering its behavior. | import System.IO (hFlush, stdout)
main = do
putStr "Enter a string: "
hFlush stdout
str <- getLine
putStr "Enter an integer: "
hFlush stdout
num <- readLn :: IO Int
putStrLn $ str ++ (show num)
| #!/usr/bin/php
<?php
$string = fgets(STDIN);
$integer = (int) fgets(STDIN);
|
Write the same algorithm in PHP as shown in this Icon implementation. | procedure main ()
writes ("Enter something: ")
s := read ()
write ("You entered: " || s)
writes ("Enter 75000: ")
if (i := integer (read ())) then
write (if (i = 75000) then "correct" else "incorrect")
else write ("you must enter a number")
end
| #!/usr/bin/php
<?php
$string = fgets(STDIN);
$integer = (int) fgets(STDIN);
|
Produce a language-to-language conversion: from J to PHP, same semantics. | require 'misc'
prompt 'Enter string: '
0".prompt 'Enter an integer: '
| #!/usr/bin/php
<?php
$string = fgets(STDIN);
$integer = (int) fgets(STDIN);
|
Ensure the translated PHP code behaves exactly like the original Julia snippet. | print("String? ")
y = readline()
println("Your input was \"", y, "\".\n")
print("Integer? ")
y = readline()
try
y = parse(Int, y)
println("Your input was \"", y, "\".\n")
catch
println("Sorry, but \"", y, "\" does not compute as an integer.")
end
| #!/usr/bin/php
<?php
$string = fgets(STDIN);
$integer = (int) fgets(STDIN);
|
Please provide an equivalent version of this Lua code in PHP. | print('Enter a string: ')
s = io.stdin:read()
print('Enter a number: ')
i = tonumber(io.stdin:read())
| #!/usr/bin/php
<?php
$string = fgets(STDIN);
$integer = (int) fgets(STDIN);
|
Transform the following Mathematica implementation into PHP, maintaining the same output and logic. | mystring = InputString["give me a string please"];
myinteger = Input["give me an integer please"];
| #!/usr/bin/php
<?php
$string = fgets(STDIN);
$integer = (int) fgets(STDIN);
|
Produce a language-to-language conversion: from MATLAB to PHP, same semantics. | >> input('Input string: ')
Input string: 'Hello'
ans =
Hello
>> input('Input number: ')
Input number: 75000
ans =
75000
>> input('Input number, the number will be stored as a string: ','s')
Input number, the number will be stored as a string: 75000
ans =
75000
| #!/usr/bin/php
<?php
$string = fgets(STDIN);
$integer = (int) fgets(STDIN);
|
Translate this program into PHP but keep the logic exactly as in Nim. | import rdstdin, strutils
let str = readLineFromStdin "Input a string: "
let num = parseInt(readLineFromStdin "Input an integer: ")
| #!/usr/bin/php
<?php
$string = fgets(STDIN);
$integer = (int) fgets(STDIN);
|
Generate an equivalent PHP version of this OCaml code. | print_string "Enter a string: ";
let str = read_line () in
print_string "Enter an integer: ";
let num = read_int () in
Printf.printf "%s%d\n" str num
| #!/usr/bin/php
<?php
$string = fgets(STDIN);
$integer = (int) fgets(STDIN);
|
Translate the given Pascal code snippet into PHP without altering its behavior. | program UserInput(input, output);
var i : Integer;
s : String;
begin
write('Enter an integer: ');
readln(i);
write('Enter a string: ');
readln(s)
end.
| #!/usr/bin/php
<?php
$string = fgets(STDIN);
$integer = (int) fgets(STDIN);
|
Write the same algorithm in PHP as shown in this Perl implementation. | print "Enter a string: ";
my $string = <>;
print "Enter an integer: ";
my $integer = <>;
| #!/usr/bin/php
<?php
$string = fgets(STDIN);
$integer = (int) fgets(STDIN);
|
Translate the given PowerShell code snippet into PHP without altering its behavior. | $string = Read-Host "Input a string"
[int]$number = Read-Host "Input a number"
| #!/usr/bin/php
<?php
$string = fgets(STDIN);
$integer = (int) fgets(STDIN);
|
Convert this R snippet to PHP and keep its semantics consistent. | stringval <- readline("String: ")
intval <- as.integer(readline("Integer: "))
| #!/usr/bin/php
<?php
$string = fgets(STDIN);
$integer = (int) fgets(STDIN);
|
Rewrite the snippet below in PHP so it works the same as the original Racket code. | #lang racket
(printf "Input a string: ")
(define s (read-line))
(printf "You entered: ~a\n" s)
(printf "Input a number: ")
(define m (or (string->number (read-line))
(error "I said a number!")))
(printf "You entered: ~a\n" m)
(printf "Input a number: ")
(define n (read))
(unless (number? n) (error "I s... | #!/usr/bin/php
<?php
$string = fgets(STDIN);
$integer = (int) fgets(STDIN);
|
Write a version of this COBOL function in PHP with identical behavior. | IDENTIFICATION DIVISION.
PROGRAM-ID. Get-Input.
DATA DIVISION.
WORKING-STORAGE SECTION.
01 Input-String PIC X(30).
01 Input-Int PIC 9(5).
PROCEDURE DIVISION.
DISPLAY "Enter a string:"
ACCEPT Input-String
DISPLAY "Enter a number:"
ACCEP... | #!/usr/bin/php
<?php
$string = fgets(STDIN);
$integer = (int) fgets(STDIN);
|
Translate this program into PHP but keep the logic exactly as in REXX. |
options replace format comments java crossref symbols nobinary
checkVal = 75000
say 'Input a string then the number' checkVal
parse ask inString
parse ask inNumber .
say 'Input string:' inString
say 'Input number:' inNumber
if inNumber == checkVal then do
say 'Success! Input number is as requested'
end
else do
... | #!/usr/bin/php
<?php
$string = fgets(STDIN);
$integer = (int) fgets(STDIN);
|
Translate this program into PHP but keep the logic exactly as in Ruby. | puts "You entered:
begin
puts "You entered:
rescue ex
puts ex
end
| #!/usr/bin/php
<?php
$string = fgets(STDIN);
$integer = (int) fgets(STDIN);
|
Ensure the translated PHP code behaves exactly like the original Scala snippet. |
fun main(args: Array<String>) {
print("Enter a string : ")
val s = readLine()!!
println(s)
do {
print("Enter 75000 : ")
val number = readLine()!!.toInt()
} while (number != 75000)
}
| #!/usr/bin/php
<?php
$string = fgets(STDIN);
$integer = (int) fgets(STDIN);
|
Produce a functionally identical PHP code for the snippet given in Swift. | print("Enter a string: ", terminator: "")
if let str = readLine() {
print(str)
}
| #!/usr/bin/php
<?php
$string = fgets(STDIN);
$integer = (int) fgets(STDIN);
|
Preserve the algorithm and functionality while converting the code from Tcl to PHP. |
write "Enter a string: "
set text [readline]
set num 0
while {[canread] && $num != 75000} {
write "Enter the number 75000: "
set num [readline]
}
print $text
print $num
| #!/usr/bin/php
<?php
$string = fgets(STDIN);
$integer = (int) fgets(STDIN);
|
Write a version of this C++ function in Rust with identical behavior. | #include <iostream>
#include <string>
using namespace std;
int main()
{
long int integer_input;
string string_input;
cout << "Enter an integer: ";
cin >> integer_input;
cout << "Enter a string: ";
cin >> string_input;
return 0;
}
| use std::io::{self, Write};
use std::fmt::Display;
use std::process;
fn main() {
let s = grab_input("Give me a string")
.unwrap_or_else(|e| exit_err(&e, e.raw_os_error().unwrap_or(-1)));
println!("You entered: {}", s.trim());
let n: i32 = grab_input("Give me an integer")
.unwrap_or_else(|... |
Keep all operations the same but rewrite the snippet in Rust. | import java.util.Scanner;
public class GetInput {
public static void main(String[] args) throws Exception {
Scanner s = new Scanner(System.in);
System.out.print("Enter a string: ");
String str = s.nextLine();
System.out.print("Enter an integer: ");
int i = Integer.parseInt(s... | use std::io::{self, Write};
use std::fmt::Display;
use std::process;
fn main() {
let s = grab_input("Give me a string")
.unwrap_or_else(|e| exit_err(&e, e.raw_os_error().unwrap_or(-1)));
println!("You entered: {}", s.trim());
let n: i32 = grab_input("Give me an integer")
.unwrap_or_else(|... |
Produce a language-to-language conversion: from Go to Rust, same semantics. | package main
import "fmt"
func main() {
var s string
var i int
if _, err := fmt.Scan(&s, &i); err == nil && i == 75000 {
fmt.Println("good")
} else {
fmt.Println("wrong")
}
}
| use std::io::{self, Write};
use std::fmt::Display;
use std::process;
fn main() {
let s = grab_input("Give me a string")
.unwrap_or_else(|e| exit_err(&e, e.raw_os_error().unwrap_or(-1)));
println!("You entered: {}", s.trim());
let n: i32 = grab_input("Give me an integer")
.unwrap_or_else(|... |
Please provide an equivalent version of this Rust code in Python. | use std::io::{self, Write};
use std::fmt::Display;
use std::process;
fn main() {
let s = grab_input("Give me a string")
.unwrap_or_else(|e| exit_err(&e, e.raw_os_error().unwrap_or(-1)));
println!("You entered: {}", s.trim());
let n: i32 = grab_input("Give me an integer")
.unwrap_or_else(|... | string = raw_input("Input a string: ")
|
Port the provided C code into Rust while preserving the original functionality. | #include <stdio.h>
#include <stdlib.h>
int main(void)
{
char str[BUFSIZ];
puts("Enter a string: ");
fgets(str, sizeof(str), stdin);
long num;
char buf[BUFSIZ];
do
{
puts("Enter 75000: ");
fgets(buf, sizeof(buf), stdin);
num = strtol(buf, NULL, 10);
} w... | use std::io::{self, Write};
use std::fmt::Display;
use std::process;
fn main() {
let s = grab_input("Give me a string")
.unwrap_or_else(|e| exit_err(&e, e.raw_os_error().unwrap_or(-1)));
println!("You entered: {}", s.trim());
let n: i32 = grab_input("Give me an integer")
.unwrap_or_else(|... |
Rewrite the snippet below in Rust so it works the same as the original C# code. | using System;
namespace C_Sharp_Console {
class example {
static void Main() {
string word;
int num;
Console.Write("Enter an integer: ");
num = Console.Read();
Console.Write("Enter a String: ");
word = Console.ReadLine()... | use std::io::{self, Write};
use std::fmt::Display;
use std::process;
fn main() {
let s = grab_input("Give me a string")
.unwrap_or_else(|e| exit_err(&e, e.raw_os_error().unwrap_or(-1)));
println!("You entered: {}", s.trim());
let n: i32 = grab_input("Give me an integer")
.unwrap_or_else(|... |
Produce a language-to-language conversion: from Rust to VB, same semantics. | use std::io::{self, Write};
use std::fmt::Display;
use std::process;
fn main() {
let s = grab_input("Give me a string")
.unwrap_or_else(|e| exit_err(&e, e.raw_os_error().unwrap_or(-1)));
println!("You entered: {}", s.trim());
let n: i32 = grab_input("Give me an integer")
.unwrap_or_else(|... | Public Sub text()
Debug.Print InputBox("Input a string")
Debug.Print InputBox("Input the integer 75000", "Input an integer", 75000, Context = "Long")
End Sub
|
Write the same algorithm in C# as shown in this Ada implementation. | with Ada.Text_IO; use Ada.Text_IO;
with Ada.Calendar; use Ada.Calendar;
with Ada.Calendar.Formatting; use Ada.Calendar.Formatting;
with Ada.Calendar.Conversions; use Ada.Calendar.Conversions;
procedure ShowEpoch is
etime : Time := To_Ada_Time (0);
begin
Put_Line (Image (Date => etime));
end ShowEpoch;
| using System;
class Program
{
static void Main()
{
Console.WriteLine(new DateTime());
}
}
|
Rewrite the snippet below in C# so it works the same as the original Ada code. | with Ada.Text_IO; use Ada.Text_IO;
with Ada.Calendar; use Ada.Calendar;
with Ada.Calendar.Formatting; use Ada.Calendar.Formatting;
with Ada.Calendar.Conversions; use Ada.Calendar.Conversions;
procedure ShowEpoch is
etime : Time := To_Ada_Time (0);
begin
Put_Line (Image (Date => etime));
end ShowEpoch;
| using System;
class Program
{
static void Main()
{
Console.WriteLine(new DateTime());
}
}
|
Change the programming language of this snippet from Ada to C without modifying what it does. | with Ada.Text_IO; use Ada.Text_IO;
with Ada.Calendar; use Ada.Calendar;
with Ada.Calendar.Formatting; use Ada.Calendar.Formatting;
with Ada.Calendar.Conversions; use Ada.Calendar.Conversions;
procedure ShowEpoch is
etime : Time := To_Ada_Time (0);
begin
Put_Line (Image (Date => etime));
end ShowEpoch;
| #include <time.h>
#include <stdio.h>
int main() {
time_t t = 0;
printf("%s", asctime(gmtime(&t)));
return 0;
}
|
Translate the given Ada code snippet into C without altering its behavior. | with Ada.Text_IO; use Ada.Text_IO;
with Ada.Calendar; use Ada.Calendar;
with Ada.Calendar.Formatting; use Ada.Calendar.Formatting;
with Ada.Calendar.Conversions; use Ada.Calendar.Conversions;
procedure ShowEpoch is
etime : Time := To_Ada_Time (0);
begin
Put_Line (Image (Date => etime));
end ShowEpoch;
| #include <time.h>
#include <stdio.h>
int main() {
time_t t = 0;
printf("%s", asctime(gmtime(&t)));
return 0;
}
|
Change the programming language of this snippet from Ada to C++ without modifying what it does. | with Ada.Text_IO; use Ada.Text_IO;
with Ada.Calendar; use Ada.Calendar;
with Ada.Calendar.Formatting; use Ada.Calendar.Formatting;
with Ada.Calendar.Conversions; use Ada.Calendar.Conversions;
procedure ShowEpoch is
etime : Time := To_Ada_Time (0);
begin
Put_Line (Image (Date => etime));
end ShowEpoch;
| #include <iostream>
#include <chrono>
#include <ctime>
int main()
{
std::chrono::system_clock::time_point epoch;
std::time_t t = std::chrono::system_clock::to_time_t(epoch);
std::cout << std::asctime(std::gmtime(&t)) << '\n';
return 0;
}
|
Ensure the translated C++ code behaves exactly like the original Ada snippet. | with Ada.Text_IO; use Ada.Text_IO;
with Ada.Calendar; use Ada.Calendar;
with Ada.Calendar.Formatting; use Ada.Calendar.Formatting;
with Ada.Calendar.Conversions; use Ada.Calendar.Conversions;
procedure ShowEpoch is
etime : Time := To_Ada_Time (0);
begin
Put_Line (Image (Date => etime));
end ShowEpoch;
| #include <iostream>
#include <chrono>
#include <ctime>
int main()
{
std::chrono::system_clock::time_point epoch;
std::time_t t = std::chrono::system_clock::to_time_t(epoch);
std::cout << std::asctime(std::gmtime(&t)) << '\n';
return 0;
}
|
Translate the given Ada code snippet into Go without altering its behavior. | with Ada.Text_IO; use Ada.Text_IO;
with Ada.Calendar; use Ada.Calendar;
with Ada.Calendar.Formatting; use Ada.Calendar.Formatting;
with Ada.Calendar.Conversions; use Ada.Calendar.Conversions;
procedure ShowEpoch is
etime : Time := To_Ada_Time (0);
begin
Put_Line (Image (Date => etime));
end ShowEpoch;
| package main
import ("fmt"; "time")
func main() {
fmt.Println(time.Time{})
}
|
Change the following Ada code into Go without altering its purpose. | with Ada.Text_IO; use Ada.Text_IO;
with Ada.Calendar; use Ada.Calendar;
with Ada.Calendar.Formatting; use Ada.Calendar.Formatting;
with Ada.Calendar.Conversions; use Ada.Calendar.Conversions;
procedure ShowEpoch is
etime : Time := To_Ada_Time (0);
begin
Put_Line (Image (Date => etime));
end ShowEpoch;
| package main
import ("fmt"; "time")
func main() {
fmt.Println(time.Time{})
}
|
Write a version of this Ada function in Java with identical behavior. | with Ada.Text_IO; use Ada.Text_IO;
with Ada.Calendar; use Ada.Calendar;
with Ada.Calendar.Formatting; use Ada.Calendar.Formatting;
with Ada.Calendar.Conversions; use Ada.Calendar.Conversions;
procedure ShowEpoch is
etime : Time := To_Ada_Time (0);
begin
Put_Line (Image (Date => etime));
end ShowEpoch;
| import java.text.DateFormat;
import java.util.Date;
import java.util.TimeZone;
public class DateTest{
public static void main(String[] args) {
Date date = new Date(0);
DateFormat format = DateFormat.getDateTimeInstance();
format.setTimeZone(TimeZone.getTimeZone("UTC"));
System.out.p... |
Convert the following code from Ada to Java, ensuring the logic remains intact. | with Ada.Text_IO; use Ada.Text_IO;
with Ada.Calendar; use Ada.Calendar;
with Ada.Calendar.Formatting; use Ada.Calendar.Formatting;
with Ada.Calendar.Conversions; use Ada.Calendar.Conversions;
procedure ShowEpoch is
etime : Time := To_Ada_Time (0);
begin
Put_Line (Image (Date => etime));
end ShowEpoch;
| import java.text.DateFormat;
import java.util.Date;
import java.util.TimeZone;
public class DateTest{
public static void main(String[] args) {
Date date = new Date(0);
DateFormat format = DateFormat.getDateTimeInstance();
format.setTimeZone(TimeZone.getTimeZone("UTC"));
System.out.p... |
Please provide an equivalent version of this Ada code in Python. | with Ada.Text_IO; use Ada.Text_IO;
with Ada.Calendar; use Ada.Calendar;
with Ada.Calendar.Formatting; use Ada.Calendar.Formatting;
with Ada.Calendar.Conversions; use Ada.Calendar.Conversions;
procedure ShowEpoch is
etime : Time := To_Ada_Time (0);
begin
Put_Line (Image (Date => etime));
end ShowEpoch;
| >>> import time
>>> time.asctime(time.gmtime(0))
'Thu Jan 1 00:00:00 1970'
>>>
|
Generate a Python translation of this Ada snippet without changing its computational steps. | with Ada.Text_IO; use Ada.Text_IO;
with Ada.Calendar; use Ada.Calendar;
with Ada.Calendar.Formatting; use Ada.Calendar.Formatting;
with Ada.Calendar.Conversions; use Ada.Calendar.Conversions;
procedure ShowEpoch is
etime : Time := To_Ada_Time (0);
begin
Put_Line (Image (Date => etime));
end ShowEpoch;
| >>> import time
>>> time.asctime(time.gmtime(0))
'Thu Jan 1 00:00:00 1970'
>>>
|
Produce a functionally identical VB code for the snippet given in Ada. | with Ada.Text_IO; use Ada.Text_IO;
with Ada.Calendar; use Ada.Calendar;
with Ada.Calendar.Formatting; use Ada.Calendar.Formatting;
with Ada.Calendar.Conversions; use Ada.Calendar.Conversions;
procedure ShowEpoch is
etime : Time := To_Ada_Time (0);
begin
Put_Line (Image (Date => etime));
end ShowEpoch;
| Sub Main()
Debug.Print Format(0, "dd mmm yyyy hh:mm")
End Sub
|
Convert this Ada snippet to VB and keep its semantics consistent. | with Ada.Text_IO; use Ada.Text_IO;
with Ada.Calendar; use Ada.Calendar;
with Ada.Calendar.Formatting; use Ada.Calendar.Formatting;
with Ada.Calendar.Conversions; use Ada.Calendar.Conversions;
procedure ShowEpoch is
etime : Time := To_Ada_Time (0);
begin
Put_Line (Image (Date => etime));
end ShowEpoch;
| Sub Main()
Debug.Print Format(0, "dd mmm yyyy hh:mm")
End Sub
|
Can you help me rewrite this code in C instead of Arturo, keeping it the same logically? | print to :date 0
print now
print to :integer now
| #include <time.h>
#include <stdio.h>
int main() {
time_t t = 0;
printf("%s", asctime(gmtime(&t)));
return 0;
}
|
Produce a language-to-language conversion: from Arturo to C, same semantics. | print to :date 0
print now
print to :integer now
| #include <time.h>
#include <stdio.h>
int main() {
time_t t = 0;
printf("%s", asctime(gmtime(&t)));
return 0;
}
|
Rewrite the snippet below in C# so it works the same as the original Arturo code. | print to :date 0
print now
print to :integer now
| using System;
class Program
{
static void Main()
{
Console.WriteLine(new DateTime());
}
}
|
Maintain the same structure and functionality when rewriting this code in C#. | print to :date 0
print now
print to :integer now
| using System;
class Program
{
static void Main()
{
Console.WriteLine(new DateTime());
}
}
|
Rewrite this program in C++ while keeping its functionality equivalent to the Arturo version. | print to :date 0
print now
print to :integer now
| #include <iostream>
#include <chrono>
#include <ctime>
int main()
{
std::chrono::system_clock::time_point epoch;
std::time_t t = std::chrono::system_clock::to_time_t(epoch);
std::cout << std::asctime(std::gmtime(&t)) << '\n';
return 0;
}
|
Generate a C++ translation of this Arturo snippet without changing its computational steps. | print to :date 0
print now
print to :integer now
| #include <iostream>
#include <chrono>
#include <ctime>
int main()
{
std::chrono::system_clock::time_point epoch;
std::time_t t = std::chrono::system_clock::to_time_t(epoch);
std::cout << std::asctime(std::gmtime(&t)) << '\n';
return 0;
}
|
Convert this Arturo snippet to Java and keep its semantics consistent. | print to :date 0
print now
print to :integer now
| import java.text.DateFormat;
import java.util.Date;
import java.util.TimeZone;
public class DateTest{
public static void main(String[] args) {
Date date = new Date(0);
DateFormat format = DateFormat.getDateTimeInstance();
format.setTimeZone(TimeZone.getTimeZone("UTC"));
System.out.p... |
Port the following code from Arturo to Java with equivalent syntax and logic. | print to :date 0
print now
print to :integer now
| import java.text.DateFormat;
import java.util.Date;
import java.util.TimeZone;
public class DateTest{
public static void main(String[] args) {
Date date = new Date(0);
DateFormat format = DateFormat.getDateTimeInstance();
format.setTimeZone(TimeZone.getTimeZone("UTC"));
System.out.p... |
Write the same algorithm in Python as shown in this Arturo implementation. | print to :date 0
print now
print to :integer now
| >>> import time
>>> time.asctime(time.gmtime(0))
'Thu Jan 1 00:00:00 1970'
>>>
|
Preserve the algorithm and functionality while converting the code from Arturo to Python. | print to :date 0
print now
print to :integer now
| >>> import time
>>> time.asctime(time.gmtime(0))
'Thu Jan 1 00:00:00 1970'
>>>
|
Transform the following Arturo implementation into VB, maintaining the same output and logic. | print to :date 0
print now
print to :integer now
| Sub Main()
Debug.Print Format(0, "dd mmm yyyy hh:mm")
End Sub
|
Maintain the same structure and functionality when rewriting this code in VB. | print to :date 0
print now
print to :integer now
| Sub Main()
Debug.Print Format(0, "dd mmm yyyy hh:mm")
End Sub
|
Transform the following Arturo implementation into Go, maintaining the same output and logic. | print to :date 0
print now
print to :integer now
| package main
import ("fmt"; "time")
func main() {
fmt.Println(time.Time{})
}
|
Convert this Arturo block to Go, preserving its control flow and logic. | print to :date 0
print now
print to :integer now
| package main
import ("fmt"; "time")
func main() {
fmt.Println(time.Time{})
}
|
Rewrite the snippet below in C so it works the same as the original AWK code. |
BEGIN {
print(strftime("%Y-%m-%d %H:%M:%S",0,1))
exit(0)
}
| #include <time.h>
#include <stdio.h>
int main() {
time_t t = 0;
printf("%s", asctime(gmtime(&t)));
return 0;
}
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.