Day 0: Hello, World.
Day 0: Hello, World.
+ 0 comments other way to understand in java
public class Solution { public static void main(String[] args) { // Create a Scanner object to read input from stdin. Scanner scan = new Scanner(System.in); // Read a full line of input from stdin and save it to our variable, inputUser. String inputUser = scan.nextLine(); // Close the scanner object, because we've finished reading // all of the input from stdin needed for this challenge. scan.close(); // Print a string literal saying "Hello, World." + the variable inputUser to stdout. System.out.println("Hello, World.\n" + inputUser); // TODO: Write a line of code here that prints the contents of inputUser to stdout. } }
+ 1 comment easy to understand solution in C++ for beginners
#include <cmath> #include <cstdio> #include <vector> #include <iostream> #include <algorithm> #include <map> using namespace std; int N = 1e4; int main() { vector<char> arr; char* str = new char[N]; cin.getline(str, N); int i = 0; while (str[i] != '\0') { arr.push_back(str[i]); i++; } delete[] str; string result; vector<string> st = {"Hello,", "World."}; for (size_t i = 0; i < st.size(); ++i) { result += st[i]; if (i < st.size() - 1) { result += " "; } } cout << result << endl; map<int, char> myMap; for (int i = 0; i < arr.size(); ++i) { myMap.insert({i, arr[i]}); } for (auto& entry : myMap) { cout << entry.second; } cout << endl; return 0; }
+ 0 comments Read a full line of input from stdin and save it to our dynamically typed variable, input_string.
input_string = input()
Print a string literal saying "Hello, World." to stdout.
print('Hello, World.')
print(input_string)
TODO: Write a line of code here that prints the contents of input_string to stdout.
+ 0 comments this is an example of using the golang language, by adding the bufio and os packages so you can see if there are any more sentences after the first sentence
package main import( "fmt" "bufio" "os" )
func main() { //Enter your code here. Read input from STDIN. Print output to STDOUT inputString := bufio.NewScanner(os.Stdin) for inputString.Scan() { fmt.Println("Hello, World.") fmt.Println(inputString.Text()) // Println will add back the final '\n' } if err := inputString.Err(); err != nil { fmt.Fprintln(os.Stderr, "reading standard input:", err) } }
+ 0 comments print('Hello, World.') for i in inputString: print(i,end = "")
Sort 2041 Discussions, By:
Please Login in order to post a comment