New Ket Network online problem system JavaScript (V8) use

Source: Internet
Author: User

JavaScript, as a weak type of programming language, syntax and C + +, Java and other differences, but for the large algorithm problem, not only C + +, JAVA, also can still use JavaScript to achieve. So in the cattle network, if you like the JavaScript programming language, but also interested in data structures and algorithms, of course, you can use this language to brush programming problems.

Have you ever met me with a similar situation, in the cattle and the network brush programming problems, the compiler provides JavaScript (V8 6.0.0), the online programming part of the front-end programming is OK, only used in the function of the topic to supplement the line. But the trouble is that we don't know how to implement input like C/C + +, similar to the scanf and the CIN functions of the C. C + +. Because JavaScript is basically functional programming, the program is all encapsulated in the function, and then called the function, through the console console or node console to view the results. The prerequisite is that the input has already been specified. As a result, the test case of the online problem system of the cattle network can not be passed in any way, because the input of his test case cannot be passed in at all.

The main reason, in fact, or the cattle network has provided a solution for JavaScript (V8 6.0.0), here a brief introduction, I hope to be helpful to everyone.

The following is a sample code for the A+b topic, http://www.nowcoder.com/questionTerminal/dae9959d6df7466d9a1f6d70d6a11417

Calculates the a+b and, each line of package line two integers a and B, for each line of input corresponding to the output line A and B and, distance:

Input

1 5

2 6

Output

6

8

(1) Select JavaScript (V8 6.0.0)

(2) Get input (Note: ReadLine gets a string, this example needs to be converted to a number)

 while (line=ReadLine ()) {    var lines = Line.split (');  //String conversion to character array      var a = parseint (lines[0]);     var b = parseint (lines[1]);    Print (a+b);}

Of course, if it's a function, it could be like this.

 while (line=ReadLine ()) {:    var lines = Line.split (");     var a = parseint (lines[0]);     var b = parseint (lines[1]);     function Add (m,n) {        return m+n;    }    Print (Add (A,b));}

(3) Submit run, can view use case

Reference: Online problem solving system for cattle and guest network use Help

New Ket Network online problem system JavaScript (V8) use

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.