C 练习实例80

C 语言教程 · 2019-02-22 13:56:51

题目:海滩上有一堆桃子,五只猴子来分。第一只猴子把这堆桃子平均分为五份,多了一个,这只 猴子把多的一个扔入海中,拿走了一份。第二只猴子把剩下的桃子又平均分成五份,又多了 一个,它同样把多的一个扔入海中,拿走了一份,第三、第四、第五只猴子都是这样做的, 问海滩上原来最少有多少个桃子?

程序分析:无。

程序源代码:

//  Created by www.codercto.com on 15/11/9.
//  Copyright © 2015年 码农教程. All rights reserved.
//

#include<stdio.h>
#include<stdlib.h>
int main()
{
    int x
    ,i=0,j=1;
    while(i<5){
        x=4*j;
        for(i=0;i<5;i++)
        {
            if(x%4!=0){break;}
            x=(x/4)*5+1;
        }
        j++;
    }
    printf("%d\n",x);
    
    return 0;
}

以上实例运行输出结果为:

3121

点击查看所有 C 语言教程 文章: https://codercto.com/courses/l/17.html

查看所有标签

Basics of Web Design

Basics of Web Design

Terry Felke-Morris / Addison-Wesley / 2013-1-28 / USD 98.40

Basics of Web Design: HTML5 and CSS3, 2e covers the basic concepts that web designers need to develop their skills: * Introductory Internet and Web concepts* Creating web pages with HTML5* Configurin......一起来看看 《Basics of Web Design》 这本书的介绍吧!

CSS 压缩/解压工具
CSS 压缩/解压工具

在线压缩/解压 CSS 代码

RGB CMYK 转换工具
RGB CMYK 转换工具

RGB CMYK 互转工具