72.c

来自「C++游戏开发书籍的实例非常适合初学但又又想往游戏开发方面发展的人学习哦」· C语言 代码 · 共 25 行

C
25
字号
#include<stdio.h>
void main()
{
    int i=1;                  /*i为所设的阶梯数*/
    clrscr();
    puts("**************************************************");
    puts("*        This program is to solve                *");
    puts("*     Einstein's interesting math question,      *");
    puts("*   which is presented by Albert Einstein,       *");
    puts("*       a famous theoretical physicist.          *");
    puts("* The Problem is as follows: there is a long     *");
    puts("* ladder, if one step strides 2 stages, 1 stages *");
    puts("* left, if one step strides 3 stages, 2 stages   *");
    puts("* left, if one step strides 5 stages, 4 stages   *");
    puts("* left, if one step strides 7 stages, 0 stages   *");
    puts("* left, the question is, how many stages has     *");
    puts("* the ladder?                                    *");
    puts("**************************************************");
    while(!((i%2==1)&&(i%3==2)&&(i%5==4)&&(i%6==5)&&(i%7==0)))
        ++i;                  /*满足一组同余式的判别*/
    printf("\n >> The ladder has %d stages.\n",i);
    puts("\n Press any key to quit...");
    getch();
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?