看板 NTUEE108HW 關於我們 聯絡資訊
Use both a switch and a while statement to control the program execution, such that the user can choose several consecutive computations provided by your pr ogram until the user enters an EOF character that quits the program 有人可以教我那個輸入EOF停止程式的碼要怎麼寫嗎? 我寫出來的按ctrl+z 再enter就會陷入無窮迴圈~>< ---- 這是我寫的 cout<<"\nEnter 's' to sort an array, 't' to tokenize a sentence:"; cin>>command; while(command!= EOF){ switch(command){ case's': break; case't': break; default: break; } cout<<"\nEnter 's' to sort an array, 't' to tokenize a sentence:"; cin>>command; } -- 薛丁格和海森堡開車上路 海森堡:「嘿,我想你剛壓到一隻貓了。」 薛丁格:「牠死了嗎?」 海森堡:「我測不準哩!」 -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 140.112.240.164
timrau:while(cin>>command) 140.112.25.138 11/28
davidlue:可以了,謝謝~^^ 140.112.240.164 11/28