Skip to content

Commit a3a1e03

Browse files
committed
More day1 solutions
1 parent 61113f9 commit a3a1e03

File tree

6 files changed

+34
-15
lines changed

6 files changed

+34
-15
lines changed

Day1-HelloWorld/C++/main.c

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,11 @@
1-
#include <cmath>
2-
#include <cstdio>
3-
#include <vector>
41
#include <iostream>
5-
#include <algorithm>
2+
63
using namespace std;
4+
75
int main() {
8-
string input_string;
9-
getline(cin, input_string);
10-
cout << "Hello, World." << endl;
11-
cout << input_string;
12-
return 0;
6+
string inputString;
7+
getline(cin, inputString);
8+
cout << "Hello, World." << endl;
9+
cout << inputString;
10+
return 0;
1311
}

Day1-HelloWorld/C/main.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
int main() {
2+
char inputString[105];
3+
scanf("%[^\n]", inputString);
4+
printf("Hello, World.\n");
5+
printf("%s", inputString);
6+
return 0;
7+
}

Day1-HelloWorld/Java/main.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
public class Solution {
2+
public static void main(String[] args) {
3+
Scanner scan = new Scanner(System.in);
4+
String inputString = scan.nextLine();
5+
scan.close();
6+
System.out.println("Hello, World.");
7+
System.out.println(inputString);
8+
}
9+
}

Day1-HelloWorld/Javascript/main.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
function processData(inputString) {
2+
console.log("Hello, World.");
3+
console.log(inputString);
4+
}

Day1-HelloWorld/README.md

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,18 @@
11
## Objective
2-
In this challenge, we review some basic concepts that will get you started with this series. You will need to use the same (or similar) syntax to read input and write output in challenges throughout HackerRank. Check out the Tutorial tab for learning materials and an instructional video!
2+
In this challenge, some basic concepts that will get you started with this series are reviewed. You will need to use the same (or similar) syntax to read input and write output in challenges.
33

44
## Task
55
To complete this challenge, you must save a line of input from stdin to a variable, print Hello, World. on a single line, and finally print the value of your variable on a second line.
66

77
You've got this!
88

9-
Note: The instructions are Java-based, but we support submissions in many popular languages. You can switch languages using the drop-down menu above your editor, and the variable may be written differently depending on the best-practice conventions of your submission language.
10-
119
## Input Format
1210

13-
A single line of text denoting (the variable whose contents must be printed).
11+
A single line of text denoting the variable whose contents must be printed.
1412

1513
## Output Format
1614

17-
Print Hello, World. on the first line, and the contents of on the second line.
15+
Print Hello, World. on the first line, and the contents of variable on the second line.
1816

1917
## Sample Input
2018
```
@@ -29,4 +27,4 @@ Welcome to 30 Days of Code!
2927

3028
## Explanation
3129

32-
On the first line, we print the string literal Hello, World.. On the second line, we print the contents of the variable which, for this sample case, happens to be Welcome to 30 Days of Code!. If you do not print the variable's contents to stdout, you will not pass the hidden test case.
30+
On the first line, we print the string literal Hello, World. On the second line, we print the contents of the variable which, for this sample case, happens to be Welcome to 30 Days of Code!.

Day1-HelloWorld/Swift/main.swift

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
let inputString = readLine()!
2+
print("Hello, World.")
3+
print(inputString)

0 commit comments

Comments
 (0)