m0_62858403 2021-11-15 13:27 采纳率: 100%
浏览 51
已结题

新手入门求大神们指点🙏

img

  • 写回答

2条回答 默认 最新

  • Admini$trat0r .net领域新星创作者 2021-11-15 14:52
    关注

    img

    #include <iostream>
    using namespace std;
    int main()
    {
        const string pyh = "潘阳湖";
        const string dth = "洞庭湖";
        const string th = "太湖";
        const string hzh = "洪泽湖";
        
        string a[4] = {dth,th,pyh,hzh};
        string b[4] = {hzh,pyh,th,dth};
        string c1[4] = {th,pyh,dth,hzh};
        string c2[4] = {pyh,th,dth,hzh};
        string d[4] = {pyh,hzh,dth,th};
        
        string array[4] = {pyh, dth, th, hzh};
        string result[4];
        
        for (int i = 0; i < 4; i ++)
        {
            result[0] = array[i];
            for (int j = 0; j < 4; j ++)
            {
                if (i == j)continue;
                result[1] = array[j];
                for (int k = 0; k < 4; k ++)
                {
                    if (i == k || j == k)continue;
                    result[2] = array[k];
                    for (int l = 0; l < 4; l ++)
                    {
                        if (i ==l || j == l || k == l)continue;
                        result[3] = array[l];
                        
                        int aint = (a[i] == result[i]) + (a[j] == result[j]) + (a[k] == result[k]) + (a[l] == result[l]);
                        int bint = (b[i] == result[i]) + (b[j] == result[j]) + (b[k] == result[k]) + (b[l] == result[l]);
                        int c1int = (c1[i] == result[i]) + (c1[j] == result[j]) + (c1[k] == result[k]) + (c1[l] == result[l]);
                        int c2int = (c2[i] == result[i]) + (c2[j] == result[j]) + (c2[k] == result[k]) + (c2[l] == result[l]);
                        int dint = (c2[i] == result[i]) + (d[j] == result[j]) + (d[k] == result[k]) + (d[l] == result[l]);
    
                        if (aint == 1 && bint == 1 && (c1int == 1 || c2int == 1) && dint == 1)
                        {
                            cout<<i<<j<<k<<l<<endl;                        
                            cout<<result[i]<<result[j]<<result[k]<<result[l]<<endl;
                        }
                        
                    }
                }
            }
        }
    }
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

问题事件

  • 系统已结题 12月13日
  • 已采纳回答 12月5日
  • 创建了问题 11月15日

悬赏问题

  • ¥20 西门子S7-Graph,S7-300,梯形图
  • ¥50 用易语言http 访问不了网页
  • ¥50 safari浏览器fetch提交数据后数据丢失问题
  • ¥15 matlab不知道怎么改,求解答!!
  • ¥15 永磁直线电机的电流环pi调不出来
  • ¥15 用stata实现聚类的代码
  • ¥15 请问paddlehub能支持移动端开发吗?在Android studio上该如何部署?
  • ¥20 docker里部署springboot项目,访问不到扬声器
  • ¥15 netty整合springboot之后自动重连失效
  • ¥15 悬赏!微信开发者工具报错,求帮改