1. 360使用的编程环境(OJ系统)
http://oj.acmcoder.com/ExamNotice.html 对于OJ系统进行了说明。
http://exercise.acmcoder.com/quesexcuse?paperId=213 这就是360的题
下面的代码输出的是a+b, line是用于输入的。
var line; while(line = read_line()){ line = line.split(‘ ‘); print(parseInt(line[0]) + parseInt(line[1])); }
2.网易使用的编程环境(牛客网提供OJ系统)
https://www.nowcoder.com/discuss/276
var readline = require(‘readline‘); const rl = readline.createInterface({ input: process.stdin, output: process.stdout }); rl.on(‘line‘, function(line){ var tokens = line.split(‘ ‘); console.log(parseInt(tokens[0]) + parseInt(tokens[1])); });
第一句是指引入了readline文件,第二句是指设定rl的输入输出为标准输入输出。第三句的意思就是输入为line的函数,第四句的意思就是将输入以空格分为数组。 第五句就是使用console.log()输出。
3.牛客网上的剑指offer方法又略有不同:(OJ系统)
例: 这里实现的是将一个字符串中的空格使用%20替换。
function replaceSpace(str) { // write code here
} module.exports = { replaceSpace : replaceSpace };
这里最后只要在函数内return 出希望返回的值即可。
原文:http://www.cnblogs.com/zhuzhenwei918/p/6617624.html