Re: [問題] 新手的小問題
看板C_and_CPP (C/C++)作者ioioioioioio (~溫暖小太陽~)時間16年前 (2009/08/10 16:07)推噓0(0推 0噓 0→)留言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
討論串 (同標題文章)
完整討論串 (本文為第 2 之 3 篇):
1
6
C_and_CPP 近期熱門文章
PTT數位生活區 即時熱門文章