090.约瑟夫问题

简介: 090.约瑟夫问题
#include<stdio.h>
void main()
{
    int x,y,z;
    clrscr();
    puts("****************************************************************");
    puts("*  This program is to solve Problem of Bridegroom and Bride.   *");
    puts("* The Problem is as follows: Someone goes to 3 couples lovers' *");
    puts("* wedding. The bridegrooms are A,B,C and the brides are X,Y,Z. *");
    puts("* He wants to know who marries who and asks them. A says he    *");
    puts("* will marry to X, X says her fiance is C, C says he will marry*");
    puts("* to Z. The man knows that they are all kidding. What they said*");
    puts("* is not true. So try to find who will marry to who?           *");
    puts("****************************************************************");
    puts(" >> The solutions are:");
    printf("---------------------------------------------\n");
    for(x=1;x<=3;x++)          /*穷举x的全部可能配偶*/
        for(y=1;y<=3;y++)      /*穷举y的全部可能配偶*/
            for(z=1;z<=3;z++)    /*穷举z的全部可能配偶*/
                if(x!=1&&x!=3&&z!=3&&x!=y&&x!=z&&y!=z)  /*判断配偶是否满足题意*/
                {
        printf(" X will marry to %c.\n",'A'+x-1);    /*打印判断结果*/
        printf(" Y will marry to %c.\n",'A'+y-1);
        printf(" Z will marry to %c.\n",'A'+z-1);
                }
    printf("---------------------------------------------\n");
    printf(" Press any key to quit...");
    getch();
}
相关文章
|
分布式计算 DataWorks 调度
oss数据同步maxcompute报错
在使用阿里云DataWorks同步OSS数据至MaxCompute时,遇到“Input is not in the .gz format”的报错。问题源于目标目录中存在一个空文件,导致同步时识别错误。
|
12月前
|
XML Java 测试技术
从零开始学 Maven:简化 Java 项目的构建与管理
Maven 是一个由 Apache 软件基金会开发的项目管理和构建自动化工具。它主要用在 Java 项目中,但也可以用于其他类型的项目。
555 1
从零开始学 Maven:简化 Java 项目的构建与管理
ThreeJs模拟工厂生产过程七
这篇文章详细介绍了如何在Three.js中为工厂车间的货架动态生成并放置货物,通过循环逻辑和贴图应用使货架上的物品更加逼真,增强了场景的真实感。
176 0
|
NoSQL Java Redis
|
Android开发
error: GLES2/gl2.h: No such file or directory
error: GLES2/gl2.h: No such file or directory
|
并行计算 Shell Docker
【环境配置】Ubuntu16.04安装nvidia-docker
【环境配置】Ubuntu16.04安装nvidia-docker
480 2
|
机器学习/深度学习 算法 数据挖掘
深度学习500问——Chapter05: 卷积神经网络(CNN)(4)
深度学习500问——Chapter05: 卷积神经网络(CNN)(4)
192 1
|
关系型数据库 MySQL Linux
DolphinScheduler2.x 伪分布式部署
DolphinScheduler2.x 伪分布式部署
422 0
|
机器学习/深度学习 编解码 自然语言处理
ICCV 2023 | SwiftFormer:基于Transformer的实时移动视觉应用中的高效加性注意
ICCV 2023 | SwiftFormer:基于Transformer的实时移动视觉应用中的高效加性注意
317 2
|
消息中间件 运维 监控
揭秘Kafka拦截器的神奇操作
揭秘Kafka拦截器的神奇操作
321 0