[問題] 程式的改寫
Please rewrite the code segment shown below in a "while" statement
and a "for" statement in C++:
total=0;
do{
cin>>grade;
if(grade!=-1)
total+=grade;
}while(grade!=-1);
這題我的想法是: total=0;
while(grade!=-1)
{
cin>>grade;
total+=grade;
}
不知道這樣有符合題目要求並且維持原意嗎?
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 122.116.208.81
→
02/10 16:34, , 1F
02/10 16:34, 1F
討論串 (同標題文章)