当前位置:网站首页>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 !
边栏推荐
- 三翼鸟两周年:羽翼渐丰,腾飞指日可待
- Answer: can the audio be set to on by default during easydss video on demand?
- Jerry's watch modifies the alarm clock [chapter]
- Gee learning notes 2
- What are eNB, EPC and PGW?
- 国内首款、完全自主、基于云架构的三维CAD平台——CrownCAD(皇冠CAD)
- Record idea shortcut keys
- ADB basic commands
- net share
- Should I have a separate interface assembly- Should I have a separate assembly for interfaces?
猜你喜欢
Gee learning notes 2
题解《子数整数》、《欢乐地跳》、《开灯》
Domestic free data warehouse ETL dispatching automation operation and maintenance expert taskctl
EasyDSS点播服务分享时间出错如何修改?
Unity SKFramework框架(十三)、Question 问题模块
研究表明“气味相投”更易成为朋友
Unity SKFramework框架(十六)、Package Manager 开发工具包管理器
[error record] cannot open "XXX" because Apple cannot check whether it contains malware
OpenFOAM:lduMatrix&lduAddressing
基于ssm+jsp框架实现的学生选课信息管理系统【源码+数据库】
随机推荐
Explanation of 34 common terms on the Internet
Jerry's weather direction coding table [chapter]
Clean up system cache and free memory under Linux
[indomitable medal activity] life goes on and writing goes on
Fundamentals of face recognition (facenet)
Partner cloud form strong upgrade! Pro version, more extraordinary!
leetcode621. 任务调度器
[Unity]使用GB2312,打包后程序不正常解决方案
SSL证书的分类有哪些?如何选择合适的SSL证书?
Unity skframework framework (XX), VFX lab special effects library
How to modify the error of easydss on demand service sharing time?
Unity skframework framework (XIV), extension extension function
【OpenGL】笔记二十九、高级光照(镜面高光)
Jerry's watch delete alarm clock [chapter]
Why is the default of switch followed by break?
二、帧模式 MPLS 操作
Unity SKFramework框架(二十)、VFX Lab 特效库
为什么switch 的default后面要跟break?
Gee learning notes 2
Verification failed, please check your call back website. You can follow the instructions