当前位置:网站首页>Daily practice of C language --- monkeys divide peaches
Daily practice of C language --- monkeys divide peaches
2022-07-02 13:30:00 【Edsu】
subject :
There is a pile of peaches on the beach , Five monkeys to share . The first monkey divided the pile of peaches into five parts , More One , The monkey threw one more into the sea , Took a share of . The second monkey divided the remaining peaches equally In five , One more , It also throws one more into the sea , Took a share of , Third 、 Fourth 、 Fifth Monkeys do this , Ask how many peaches there used to be on the beach ?
The code analysis :
#include <stdio.h>
#include<stdlib.h>
int main(){
int x=0,i=0,j=1;//i Indicates the number of times of execution
while(i<5){//j It means the number of peaches the monkey finally got
x=4*j;
for(i=0;i<5;i++){
if(x%4!=0)
break;
x=(x/4)*5+1;}
j++;}
printf("%d\n",x);// After averaging each time , Take the total after .
return 0;
}
Code effect :
Monkeys at least used to have 3121 A peach !
边栏推荐
- 【笔耕不辍勋章活动】生命不止,写作不息
- How to get the operating system running PHP- How to get the OS on which PHP is running?
- Unity SKFramework框架(十九)、POI 兴趣点/信息点
- Professor of Shanghai Jiaotong University: he Yuanjun - bounding box (containment / bounding box)
- How much do you know about free SSL certificates? The difference between free SSL certificate and charged SSL certificate
- Fundamentals of face recognition (facenet)
- linux下清理系统缓存并释放内存
- mac(macos Monterey12.2 m1) 个人使用php开发
- Unity SKFramework框架(十六)、Package Manager 開發工具包管理器
- Clean up system cache and free memory under Linux
猜你喜欢
Unforgettable Ali, 4 skills, 5 hr additional written tests, it's really difficult and sad to walk
题解《子数整数》、《欢乐地跳》、《开灯》
Professor of Shanghai Jiaotong University: he Yuanjun - bounding box (containment / bounding box)
[cloud native database] what to do when encountering slow SQL (Part 1)?
Three methods of finding LCA of the nearest common ancestor
2022 Heilongjiang provincial examination on the writing skills of Application Essays
De4000h storage installation configuration
Redis数据库持久化
Lucky numbers in the [leetcode daily question] matrix
The second anniversary of the three winged bird: the wings are getting richer and the take-off is just around the corner
随机推荐
MAC (MacOS Monterey 12.2 M1) personal use PHP development
mac(macos Monterey12.2 m1) 个人使用php开发
Can automatically update the universal weekly report template, you can use it with your hand!
【云原生数据库】遇到慢SQL该怎么办(上)?
题解:《压缩技术》(原版、续集版)
[youcans' image processing learning course] general contents
D如何检查null
免费SSL证书知多少?免费SSL证书和收费SSL证书的区别
nohup命令
文件的下载与图片的预览
2022 Heilongjiang provincial examination on the writing skills of Application Essays
Unforgettable Ali, 4 skills, 5 hr additional written tests, it's really difficult and sad to walk
Answer: can the audio be set to on by default during easydss video on demand?
Tupang multi-target tracking! BOT sort: robust correlated multi pedestrian tracking
SAP MM 因物料有负库存导致MMPV开账期失败问题之对策
Achievements in science and Technology (27)
国内首款、完全自主、基于云架构的三维CAD平台——CrownCAD(皇冠CAD)
Nohup command
When tidb meets Flink: tidb efficiently enters the lake "new play" | tilaker team interview
口袋奇兵点评