13
Jul.2008
猴子吃桃问题。猴子第一天摘下若干桃子,当即吃了一半,还不过瘾,又多吃了一个。第二天早上又将剩下的桃子吃了一半,有多吃了一个。以后每天早上都吃了剩下桃子的一半另加一个。到第10天早上想吃时,就只剩一个桃子了。求第一天共摘下了多少桃子。
#include<iostream>
using namespace std;
int main()
{
int num=1;
for(int i=1;i<=9;i++)
{
num=(num+1)*2;
cout<<"the "<<10-i<<"th day have "<<num<<" peaches"<<endl;
}
cout<<"the total number of the peaches is "<<num<<endl;
cout<<"Oh,my god! the monkey is very great ,it can get "<<num<<" peaches in one day by itself"<<endl;
return 0;
}
#include<iostream>
using namespace std;
int main()
{
int num=1;
for(int i=1;i<=9;i++)
{
num=(num+1)*2;
cout<<"the "<<10-i<<"th day have "<<num<<" peaches"<<endl;
}
cout<<"the total number of the peaches is "<<num<<endl;
cout<<"Oh,my god! the monkey is very great ,it can get "<<num<<" peaches in one day by itself"<<endl;
return 0;
}
作者:菜鸟学编程@点网
地址:http://www.node-net.org/post/hou-zi-chi-tao-wen-ti_9796.php
版权所有©转载时必须以链接形式注明作者和原始出处及本声明!
boli2r2v9199
2010/09/13 21:19
三十而立,明天会更加美好!
ashe2z74u8
2010/09/13 21:17
很好!很不错!
apu2n8v69r
2010/09/13 21:17
深圳加油,中国加油!!!
分页: 1/1
1
1















求一分数序列之和 2/1
用迭代法求a的平方根,求


