說明:
請撰寫一程式,將使用者輸入的五筆資料寫入到write.txt(若不存在,則讓程式建立它),每一筆資料為一行,包含學生名字和期末總分,以空白隔開。檔案寫入完成後要關閉。
範例輸入:
Leon 87
Ben 90
Sam 77
Karen 92
Kelena 92
範例輸出:
Leon 87
Ben 90
Sam 77
Karen 92
Kelena 92
範例輸出:660
Daisy
Kelvin
Tom
Joyce
Sarah
範例輸出:Append completed!
Content of "data.txt":
Ben
Cathy
Tony
Daisy
Kelvin
Tom
Joyce
Sarah
Ben 175 65
Cathy 155 55
Tony 172 75
Average height: 167.33
Average weight: 65.00
The tallest is Ben with 175.00cm
The heaviest is Tony with 75.00kg
data.txt
Tomato
範例輸出1:=== Before the deletion
Apple Kiwi Banana
Tomato Pear Durian
=== After the deletion
Apple Kiwi Banana
Pear Durian
data.txt
pen
sneakers
範例輸出:=== Before the replacement
watch shoes skirt
pen trunks pants
=== After the replacement
watch shoes skirt
sneakers trunks pants
read.txt
範例輸出:6 line(s)
102 word(s)
614 character(s)
學號 姓名 性別 科系
101 陳小華 0 餐旅管理
202 李小安 1 廣告
303 張小威 1 英文
404 羅小美 0 法文
505 陳小凱 1 日文
Number of males: 3
Number of females: 2
read.txt
3
範例輸出:a
is
programming
Karen 123456789
Bonnie 235689147
Simon 987612345
Louis 675489321
Andy 019238475
範例輸出:The content of "data.dat":
Karen 123456789
Bonnie 235689147
Simon 987612345
Louis 675489321
Andy 019238475