รุ่นที่เรียบง่ายของ เครื่องคิดเลขตัวเลขภาษาอังกฤษ
งาน
เขียนโปรแกรมที่รับสตริงเป็นอินพุตและเอาต์พุตผลลัพธ์ของนิพจน์
กฎระเบียบ
สตริงอินพุตจะถูกใช้คำและไม่ใช่ตัวเลข
จะไม่มีวงเล็บ
ลำดับการคำนวณจะถูกหารหารลบแล้วเพิ่ม
สำหรับการดำเนินการเดียวกันการคำนวณจะต้องทำจากซ้ายไปขวา
หมายเลขอินพุตทั้งหมดจะเป็นจำนวนเต็มตั้งแต่ -999 ถึง 999 (รวมทั้งคู่)
เอาต์พุตจะเป็นจำนวนเต็มของช่วงใด ๆ
การหารจะหารลงตัวได้อย่างสมบูรณ์และศูนย์จะไม่เป็นตัวหาร
การ จำกัด เคสสำหรับอินพุตเป็นทางเลือก คุณไม่ต้องตรวจสอบความถูกต้องของอินพุต
รูปแบบตัวเลข
0 to 20 -> zero,one,two...nineteen,twenty
21 to 99 -> twenty one,twenty two.....ninety eight,ninety nine
100 to 999 -> one hundred, one hundred one, one hundred two...one hundred ten....two hundred fifty....nine hundred ninety eight,nine hundred ninety nine
สำหรับตัวเลขลบ: เพิ่มminusไปยังจำนวนที่เป็นบวก
รูปแบบการดำเนินงาน
Addition: one plus two
Subtraction: one minus two
Multiplication: one time two #Note that for one on the left of multiplication, it is one time and not times.
two times one hundred
Division: forty divided by two
ตัวอย่าง:
o/p <- input
20 four times five
35 twenty plus fifteen
70 fifty plus five times four
-90 minus one time ninety
25 twenty one minus minus four
45 ninety divided by two
700 one time seven hundred
555 one hundred eleven times two plus three hundred thirty three
99 one hundred plus minus one
45 forty five plus two hundred times zero
4 four
-3 three minus three minus three
นี่คือรหัส - กอล์ฟเพื่อให้ได้รหัสที่สั้นที่สุด
one times twoผมบอกว่า ใช้งานtimeปกติหรือไม่