标题:请教大佬是否有简便些的方法
取消只看楼主
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



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-490532-1-1.html




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

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