| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 1036 人关注过本帖
标题:请教大佬是否有简便些的方法
取消只看楼主 加入收藏
grayhooo
Rank: 1
等 级:新手上路
帖 子:30
专家分:0
注 册:2018-10-11
结帖率:100%
收藏
已结贴  问题点数:15 回复次数:1 
请教大佬是否有简便些的方法
#include<stdio.h>
int main()
{   
    char str[10];
    while(scanf("%c%c",&str[1],&str[2])!=EOF)
    {
        getchar();
        scanf("%c%c%*c",&str[3],&str[4]);
        scanf("%c%c%*c",&str[5],&str[6]);
        if(str[1]==str[2]||str[3]==str[4]||str[5]==str[6])//判断AC CA形输入为错误输入
        printf("The input is not true!\n");
        if((str[1]==str[3]&&str[1]==str[5])||(str[2]==str[4]&&str[2]==str[6]))
        {
            printf("The input is not true!\n");
        }
        else
        if(str[1]==str[3]&&str[2]==str[4])
        {
            if(str[1]==str[6]&&str[2]!=str[5])
            {
            printf("%c<%c<%c\n",str[2],str[1],str[5]);}
            else
            if(str[1]!=str[6]&&str[2]==str[5])
            printf("%c<%c<%c\n",str[6],str[2],str[1]);
            else   
            printf("The input is not true!\n");
        }
        else
        if(str[1]==str[5]&&str[2]==str[6])
            {
            if(str[1]==str[4]&&str[2]!=str[3])
            {
            printf("%c<%c<%c\n",str[2],str[1],str[3]);
            }
            else
            if(str[1]!=str[4]&&str[2]==str[3])
            printf("%c<%c<%c\n",str[4],str[2],str[1]);
            else   
            printf("The input is not true!\n");
            }
        else
        if(str[3]==str[5]&&str[4]==str[6])
            {
            if(str[3]==str[2]&&str[4]!=str[1])
            {
            printf("%c<%c<%c\n",str[4],str[3],str[1]);
            }
            else
            if(str[3]!=str[2]&&str[4]==str[1])
            printf("%c<%c<%c\n",str[2],str[4],str[3]);
            else   
            printf("The input is not true!\n");
            }
        else
        if(str[1]==str[3])//str1 max
        {
            if(str[2]==str[4]||str[2]==str[6])//str2 min
            {   
                printf("%c<%c<%c\n",str[2],str[4],str[1]);
            }
            else
            if(str[4]==str[2]||str[4]==str[6])//str4 min
            {   
                printf("%c<%c<%c\n",str[4],str[2],str[1]);
            }
            else
            if(str[6]==str[2]||str[6]==str[4])//str6 min
            {   
                printf("%c<%c<%c\n",str[6],str[5],str[1]);
            }
            else
            printf("The input is not true!\n");
        }
        else
        if(str[1]==str[5])//str5 max
        {
            if(str[2]==str[4]||str[2]==str[6]) //str2 min
            {   
                printf("%c<%c<%c\n",str[2],str[3],str[1]);
            }
            else
            if(str[4]==str[2]||str[4]==str[6])//str4 min
            {   
                printf("%c<%c<%c\n",str[4],str[3],str[1]);
            }
            else
            if(str[6]==str[2]||str[6]==str[4])//str6 min
            {   
                printf("%c<%c<%c\n",str[6],str[2],str[1]);
            }
            else
            printf("The input is not true!\n");
        }
        else
        if(str[3]==str[5])//str3 min
        {
            if(str[2]==str[4]||str[2]==str[6])//str2 min
            {   
                printf("%c<%c<%c\n",str[2],str[1],str[3]);
            }
            else
            if(str[4]==str[2]||str[4]==str[6])//str4 min
            {   
                printf("%c<%c<%c\n",str[4],str[6],str[3]);
            }
            else
            if(str[6]==str[2]||str[6]==str[4])//str6 min
            {   
                printf("%c<%c<%c\n",str[6],str[4],str[3]);
            }
            else
            printf("The input is not true!\n");
        }
        else
        {printf("The input is not true!\n");}
    }
    return 0;
}
 
图片附件: 游客没有浏览图片的权限,请 登录注册


[此贴子已经被作者于2018-10-20 21:54编辑过]

搜索更多相关主题的帖子: str || printf The min 
2018-10-20 18:50
grayhooo
Rank: 1
等 级:新手上路
帖 子:30
专家分:0
注 册:2018-10-11
收藏
得分:0 
我已经找到问题了...但最后改到了120行代码 希望有大佬能给个简便的方法
2018-10-20 21:31
快速回复:请教大佬是否有简便些的方法
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.014153 second(s), 10 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved