[問題] c函式的問題
開發平台(Platform): (Ex: VC++, GCC, Linux, ...)
DEV C++
預期的正確結果(Expected Output):
0
1
2
程式碼(Code):(請善用置底文網頁, 記得排版)
void countdown(int count){
if (count != 0){
countdown(count-1);
}
printf("%d\n", count);
return;
}
int main(){
countdown(2);
system("pause");
return 0;
}
想請教一下,若printf那行寫在if之前,輸出為2->1->0。為何放在return前
輸出就成為0->1->2。
--
※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 220.137.14.49
※ 文章網址: http://www.ptt.cc/bbs/C_and_CPP/M.1397662469.A.AE7.html
→
04/16 23:42, , 1F
04/16 23:42, 1F
→
04/16 23:57, , 2F
04/16 23:57, 2F
→
04/17 00:00, , 3F
04/17 00:00, 3F
→
04/17 00:02, , 4F
04/17 00:02, 4F
→
04/17 01:04, , 5F
04/17 01:04, 5F
→
04/17 09:14, , 6F
04/17 09:14, 6F