[問題] 程式的改寫
看板C_and_CPP (C/C++)作者doggingg (doggingg)時間15年前 (2011/02/10 16:25)推噓0(0推 0噓 1→)留言1則, 1人參與討論串1/2 (看更多)
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
討論串 (同標題文章)
C_and_CPP 近期熱門文章
PTT數位生活區 即時熱門文章