目录
选择答案 :BDBAA
主要说明第一题:
解释:JavaScript 主要运行在一个内置 JavaScript 解释器的客户端中(例如 Web 浏览器),能够处理复杂的计算,操控文档的内容、样式和行为。
BDAAC
function mainJs(a,b) {
//请在此处编写代码
/***********Begin**********/
var a1 = parseInt(a);
var b1 = parseInt(b);
var c1 = a1 % b1;
var a2 = a;
var b2 = b;
var c = c1.toString();
/*********End************/
// 这里a和b变为a2和b2
return a2+b2+c;
}
function mainJs(a,b) {
//请在此处编写代码
/********Begin***************/
if (a > b) {
return a && b;
} else { return !a; }
/**********End****************/
}
function mainJs(a,b) {
//请在此处编写代码
/*********begin*********/
if (a > b) {
return a;
} else {
return b;
}
/*********end*********/
}
function mainJs(a,b) {
var a = parseInt(a);
var b = parseInt(b);
//请在此处编写代码
/*********begin*********/
var c;
var x = ((a - 1) + b) * b;
if (x == 24) {
c = 1;
} else c = 0;
var d = 4;
var e = c * d + d;
/*********end*********/
return e;
}
function mainJs(a) {
a = parseInt(a);
//请在此处编写代码
/********** Begin **********/
var sum = 0;
var i = 2;
while(i <= a) {
var j = 2;
while(j < i) {
if(i % j == 0) {
break;
}
j++;
}
if(j == i) {
sum += i;
}
i++;
}
return sum;
/********** End **********/
}
function mainJs(a,b) {
a = parseInt(a);
b = parseInt(b);
//请在此处编写代码
/********** Begin **********/
var sum = 0;
var i = a + 1;
do {
if(i < b){
sum += i;
}
i++;
} while (i < b);
return sum;
/********** End **********/
}
function mainJs(a,b) {
a = parseInt(a);
b = parseInt(b);
//请在此处编写代码
/********** Begin **********/
if (b - a == 1) {
return 1;
}
var sum = 1;
for (var i = a+1; i < b; i++) {
sum *= i;
}
return sum;
/********** End **********/
}
function mainJs(a) {
a = parseInt(a);
//请在此处编写代码
/********** Begin **********/
if (a < 60) {
return "unpass";
} else return "pass";
/********** End **********/
}
function mainJs(a) {
a = parseInt(a);
//请在此处编写代码
/********** Begin **********/
switch (a) {
case 82414:
return "Superior";
case 59600:
return "Huron";
case 58016:
return "Michigan";
case 25744:
return "Erie";
case 19554:
return "Ontario";
default:
return "error";
}
/********** End **********/
}
DBDCB
BADCC
function mainJs(a) {
a = parseInt(a);
//请在此处编写代码
/********** Begin **********/
a1 = Math.ceil(a);
a2 = Math.floor(a);
a3 = Math.round(a);
a4 = Math.sqrt(a);
a5 = Math.sin(a);
max = Math.max(a1, a2, a2, a4, a5);
min = Math.min(a1, a2, a2, a4, a5);
return max + min;
/********** End **********/
}
function mainJs(a) {
a = parseInt(a);
var date = new Date(a);
/*********Begin*********/
var time = date.getFullYear().toString() + "," +
date.getMonth().toString() + "," +
date.getDate().toString() + "," +
date.getDay().toString();
return time;
/*********End*********/
}
function mainJs(a,b) {
//请在此处编写代码
/********** Begin **********/
var x = a.indexOf(b);
var sum = 0;
while (x != -1) {
sum += x;
x = a.indexOf(b, x + b.length);
}
return sum;
/********** End **********/
}
function mainJs(a) {
//请在此处编写代码
/********** Begin **********/
var result = "";
for (var i = 0; i < 6; i++) {
result += a.charAt(i);
}
return result;
/********** End **********/
}
function mainJs(a,b) {
//请在此处编写代码
/********** Begin **********/
for (var i = 0; i < a.length; i++) {
if (a.charAt(i) == b.charAt(0)) {
a = a.slice(0, i) + a.substr(i + b.length);
}
}
return a;
/********** End **********/
}
function mainJs(a) {
//请在此处编写代码
/********** Begin **********/
var arr1 = a.split(" ");
var arr2 = a.split(",");
return arr2.length + arr1.length - 1;
/********** End **********/
}
var array1 = [1,2,3,"js",4,true,"hello"];
var array2 = [true,true,"java",2.1];
function mainJs(a) {
//请在此处编写代码
a = parseInt(a);
/*********begin*********/
if (array1.length == a) {
return array1[array1.length-1];
} else return array2[array2.length-1];
/*********end*********/
}
var testArray = [12,"java","js","c","c++",24,36,"python","c#","css"];
function mainJs(a,b) {
a = parseInt(a);
b = parseInt(b);
//请在此处编写代码
/*********begin*********/
for (var i = 1; i <= a; i++) {
var x = testArray.pop();
testArray.unshift(x);
}
return testArray[b];
/*********end*********/
}
function mainJs(myArray) {
myArray = myArray.split(",");
//请在此处编写代码
/*********begin*********/
var pos_a = [];
var pos_b = [];
for (var i = 0; i < myArray.length; i++){
if (myArray[i] == "a") {
pos_a.push(i);
}
}
for (var i = 0; i < myArray.length; i++){
if (myArray[i] == "b") {
pos_b.push(i);
}
}
var result = pos_a.concat(pos_b)
return result;
/*********end*********/
}
ADBBC
BCBDB
CDBDC
CABDA
ABCD D D A C