07-01-2008, 21:05
|
|
|
חבר מתאריך: 30.10.04
הודעות: 151
|
|
אני חושב שאולי הסתבכתי קצת יותר מדי, אבל הנה פיתרון (תוכנית מלאה) ב-C++:
קוד:
#include <iostream>
#include <cstdlib>
using namespace std;
int print(int num, const int max=5767);
int main()
{
int num;
cout << "Please enter a number: ";
cin >> num;
print(num);
system("PAUSE");
return 0;
}
int print(int num,const int max)
{
if (num>max)
return num;
cout << num << endl;
int tmp = print(num*2)/2;
cout << tmp << endl;
return tmp;
}
_____________________________________
Your signature did not follow Fresh's signatures policy, therefore it was automatically erased. Please see the E-Mail which has been sent to you, to learn how to fix this.
נערך לאחרונה ע"י PhoenixBoy בתאריך 07-01-2008 בשעה 21:08.
|