Advertisement
minnera

#30daysofcode #day0 #java

Sep 26th, 2017
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.96 KB | None | 0 0
  1. https://www.hackerrank.com/challenges/30-hello-world/
  2.  
  3. -- Example in java --
  4.  
  5. Scanner scan = new Scanner(System.in); // open scanner
  6. String s = scan.next(); // read the next token and save it to 's'
  7. scan.close(); // close scanner
  8. System.out.println(s); // print 's' to System.out, followed by a new line
  9. // - or -
  10. System.out.println("Input received: " + s);
  11.  
  12. -- Task in C# --
  13.  
  14. class Solution {
  15.     static void Main(String[] args) {
  16.         // Declare a variable named 'inputString' to hold our input.
  17.         String inputString;
  18.        
  19.         // Read a full line of input from stdin (cin) and save it to our variable, inputString.
  20.         inputString = Console.ReadLine();
  21.        
  22.         // Print a string literal saying "Hello, World." to stdout using cout.
  23.         Console.WriteLine("Hello, World.");
  24.        
  25.         // TODO: Write a line of code here that prints the contents of inputString to stdout.
  26.         Console.WriteLine(inputString);
  27.     }
  28. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement