Re: [問題] 新手的小問題

看板C_and_CPP (C/C++)作者 (~溫暖小太陽~)時間16年前 (2009/08/10 16:07), 編輯推噓0(000)
留言0則, 0人參與, 最新討論串2/3 (看更多)
int x ,y = 1; int i, flag = 0; cout <<"input a integer : " ; cin >> x; while(flag == 0) { if(x < 0) { cout << "the value : ERROR " <<endl; cout << "input an correct integer : " ; cin >> x; } else flag = 1; } if(x == 0) cout << "the value : 1" << endl; else { for (i=1; i<=x; i++) { y = y * i; } cout << "the value : " << y << endl; } 這樣就可以跑了~ 有錯請高手指證吧 小弟也是新手 哈 ^_< -- ◤◥ 喜歡請自取。 ξ ─ ─ ▄▄ -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 220.132.15.164
文章代碼(AID): #1AVzKlpv (C_and_CPP)
文章代碼(AID): #1AVzKlpv (C_and_CPP)