0

## 拜託教我這些題目的解法

!

weiclin iT邦高手 4 級 ‧ 2017-12-27 19:21:54 檢舉

https://ithelp.ithome.com.tw/questions/10186482

midterm.txt...期中考?
jaywang iT邦新手 5 級 ‧ 2017-12-27 22:28:53 檢舉

yesongow iT邦大師 1 級 ‧ 2017-12-29 12:26:37 檢舉

### 3 個回答

1
John Wu
iT邦新手 4 級 ‧ 2017-12-28 10:51:57

``````var question2 = function(n, m) {
console.log("資料筆數 " + n);
console.log("學號 姓名 (以一個空白隔開)");
console.log("查詢案件數 " + m);
console.log("查詢學號");
return "輸出對應之姓名，若無則輸出\"無此人\"";
}
``````

fillano iT邦超人 1 級 ‧ 2017-12-29 17:41:26 檢舉

``````(module
(memory (export "result") 1 1)
(func (export "test") (param \$n i32) (result i32)
(local \$ptr i32)
(local \$cur i32)
(local \$limit i32)
get_local \$n
i32.const 2
i32.gt_s
if
get_local \$n
f32.convert_u/i32
f32.sqrt
f32.ceil
i32.trunc_u/f32
set_local \$limit
i32.const 0
set_local \$ptr
i32.const 2
set_local \$cur
block \$break
loop \$while
get_local \$n
get_local \$cur
i32.rem_u
i32.const 0
i32.eq
if
get_local \$cur
call \$verify
i32.const 0
i32.eq
if
get_local \$ptr
get_local \$cur
i32.store
get_local \$ptr
i32.const 1
set_local \$ptr
end
end
get_local \$cur
i32.const 1
tee_local \$cur
get_local \$limit
i32.le_u
br_if \$while
end
end
else
i32.const 0
set_local \$ptr
end
get_local \$ptr
)
(func \$verify (param \$n i32) (result i32)
(local \$ptr i32)
(local \$cur i32)
(local \$limit i32)
get_local \$n
i32.const 2
i32.gt_s
if
get_local \$n
f32.convert_u/i32
f32.sqrt
f32.ceil
i32.trunc_u/f32
set_local \$limit
i32.const 0
set_local \$ptr
i32.const 2
set_local \$cur
block \$break
loop \$while
get_local \$n
get_local \$cur
i32.rem_u
i32.const 0
i32.eq
if
get_local \$ptr
i32.const 1
set_local \$ptr
end
get_local \$cur
i32.const 1
tee_local \$cur
get_local \$limit
i32.le_u
br_if \$while
end
end
else
i32.const 0
set_local \$ptr
end
get_local \$ptr
)
)
``````
0
martinsit011138
iT邦新手 5 級 ‧ 2017-12-30 02:57:16

0
bboy81905
iT邦新手 5 級 ‧ 2018-01-03 11:12:37

var n = 37.54
console.log(Math.floor(n10)/10);//無條件捨去到小數點第一位
console.log(Math.ceil(n
10)/10); //無條件進位