当前位置:网站首页>The problem of monkeys eating peaches in classic exercises of C language
The problem of monkeys eating peaches in classic exercises of C language
2022-07-24 04:22:00 【Serendipity_-】
The problem of monkeys eating peaches :
The monkey picked some peaches on the first day , Half eaten immediately , It's not addictive , Another one , The next morning I ate half of the rest of the peaches , Another one . After that, I ate half and one of the rest of the day before every morning . To the first 10 When I want to eat again in the morning , See there's only one peach left . Ask how much you picked on the first day .
C The program code is as follows :
/* The problem of monkeys eating peaches : The monkey picked some peaches on the first day , Half eaten immediately , It's not addictive , Another one , The next morning I ate half of the rest of the peaches , Another one . After that, I ate half and one of the rest of the day before every morning . To the first 10 When I want to eat again in the morning , See there's only one peach left . Ask how much you picked on the first day . */
#include <stdio.h>
int main(int argc, char const *argv[])
{
int n = 1;
for (int i = 9; i > 0; i--)
{
n = (n + 1) * 2;
}
printf("%d ", n);
return 0;
}
/* List all mathematical methods : (1+1)×2=4( individual ) (4+1)×2=10( individual ) (10+1)×2=22( individual ) (22+1)×2=46( individual ) (46+1)×2=94( individual ) (94+1)×2=190( individual ) (190+1)×2=382( individual ) (382+1)×2=766( individual ) (766+1)×2=1534( individual ) answer : On the first day, I picked 1534 A peach .*/
The operation result is as shown in the figure :
边栏推荐
- [untitled]
- Hardware knowledge 3 -- IIC protocol
- (零八)Flask有手就行——数据库迁移Flask-Migrate
- Collection of test case design methods
- 。 When calling, the incoming t refers to the Devi pass, which basically asks T2,
- (5) Digital electricity formula simplification method
- Alibaba Taobao Department interview question: how does redis realize inventory deduction and prevent oversold?
- How to perform chowtest with Stata
- Codeforces Round #809 (Div. 2) A - D1
- IPhone binding 163 mailbox solution
猜你喜欢

How safe is Volvo XC90? Come and have a look

(008) flask is OK if you have a hand -- database migration flask migrate

buu web
![Embedded system transplantation [6] - uboot source code structure](/img/dd/85e56360b08f49562a28ea6f6adcfd.png)
Embedded system transplantation [6] - uboot source code structure

Could NOT find Doxygen (missing: DOXYGEN_EXECUTABLE)

"Wei Lai Cup" 2022 Niuke summer multi school training camp 1 (summary of some topics)

The pit trodden by real people tells you to avoid the 10 mistakes often made in automated testing

IP second experiment mGRE OSPF

Analyze the real-time development method of Bank of London

Function application of 4G transmission module
随机推荐
How to configure Ethernet network topology in canoe network based access mode
Application scenarios and schemes of common mechanical equipment safety virtual simulation system
C语言经典习题之编写一个程序,找出1000以内所有的完数。
Successfully solved: error: SRC refspec master doors not match any
Will your NFT disappear? Dfinity provides the best solution for NFT storage
1.7.1 正误问题(中缀表达式)
Yu zhirs] below refers to the return structure push sent to the remote terminal
PostgreSQL source code learning (32) -- checkpoint ④ - core function createcheckpoint
Particle Designer:粒子效果制作器,生成plist文件并在工程中正常使用
Three cluster schemes of redis
The pit trodden by real people tells you to avoid the 10 mistakes often made in automated testing
Post it notes --46{hbuildx connect to night God simulator}
Baidu search cracking down on pirated websites: why Internet content infringement continues despite repeated prohibitions
Shell syntax (2)
Design and implementation of data analysis platform for intelligent commerce
可能有点用的冷知识
[novice] develop a tab component that is easy to expand by hand
Avoid mistakes, common appium related problems and Solutions
Shell syntax (1)
"Wei Lai Cup" 2022 Niuke summer multi school training camp 1 (summary of some topics)