"HR30 Day 0: Hello, World."의 두 판 사이의 차이

3번째 줄: 3번째 줄:
;<nowiki>Day 0: Hello, World.</nowiki>
;<nowiki>Day 0: Hello, World.</nowiki>
* https://www.hackerrank.com/challenges/30-hello-world/problem
* https://www.hackerrank.com/challenges/30-hello-world/problem
* [[해커랭크 30 Days of Code]]
{{youtube|K5WxmFfIWbo}}
{{youtube|K5WxmFfIWbo}}



2018년 7월 29일 (일) 20:57 판

1 개요

Day 0: Hello, World.

2 C

#include <stdio.h>
#include <string.h>
#include <math.h>
#include <stdlib.h>
int main() {
    char input_string[105]; 
    scanf("%[^\n]", input_string); 
    printf("Hello, World.\n");
    printf("%s\n", input_string);
    return 0;
}

3 C++

#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
using namespace std;
int main() {
    string input_string; 
    getline(cin, input_string); 
    cout << "Hello, World." << endl;
    cout << input_string << endl;
    return 0;
}

4 Go

package main
import (
    "fmt"
    "os"
    "bufio"
)
func main() {
    reader := bufio.NewReader(os.Stdin)
    input_string, _ := reader.ReadString('\n')
    fmt.Println("Hello, World.") 
    fmt.Println(input_string) 
}

5 Java

import java.io.*;
import java.util.*;
import java.text.*;
import java.math.*;
import java.util.regex.*;
public class Solution {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in); 
		String inputString = scan.nextLine(); 
		scan.close(); 
        System.out.println("Hello, World.");
        System.out.println( inputString );
	}
}

6 Node.js

function processData(inputString) {
    console.log("Hello, World.");
    console.log(inputString);
}
process.stdin.resume();
process.stdin.setEncoding("ascii");
_input = "";
process.stdin.on("data", function (input) {
    _input += input;
});

process.stdin.on("end", function () {
   processData(_input);
});

7 Perl

my $inputString = <STDIN>;
print "Hello, World.\n";
print $inputString;

8 PHP

<?php
$_fp = fopen("php://stdin", "r");
$input_string = fgets($_fp);
print("Hello, World.\n");
echo $input_string;
fclose($_fp);

9 Python

input_string = input()
print('Hello, World.')
print(input_string)

10 같이 보기

문서 댓글 ({{ doc_comments.length }})
{{ comment.name }} {{ comment.created | snstime }}