| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 537 人关注过本帖
标题:poj1013
只看楼主 加入收藏
酷爱陈阳
Rank: 2
等 级:论坛游民
帖 子:14
专家分:33
注 册:2014-11-1
结帖率:0
收藏
已结贴  问题点数:20 回复次数:2 
poj1013
#include <iostream>
#include <cstdio>
#include <cstring>
using namespace std;
int main()
{
    char left[3][5];
    char right[3][5];
    char status[3][5];
    int n;
    cin>>n;
    getchar();
    while(n--)
    {
        int i;
        for(i=0;i<3;i++)
        {
            scanf("%s",left[i]);
            scanf("%s",right[i]);
            gets(status[i]);
        }
        int x;
        int t;
        for(x='A';x<='L';x++)
        {
            int wl=0;
            int wr=0;
            int j;
            int tag;
            int flag[3][3]={0};
            for(i=0;i<3;i++)
            {
                if(status[i][0]=='e')
                    tag=0;
                else if(status[i][0]=='u')
                    tag=1;
                else
                    tag=-1;
                t=0;
                while(t<=2)
                {
                    for(j=0;j<4;j++)
                    {
                        if(x==left[i][j])
                            wl+=t;
                        else
                            wl++;
                    }
                    for(j=0;j<4;j++)
                    {
                        if(x==right[i][j])
                            wr+=t;
                        else
                            wr++;
                    }
                    if((wl-wr)==tag)
                        flag[t][i]=1;
                    t+=2;
                    wl=0;
                    wr=0;
                }
            }
            bool print=0;
            for(j=0;j<=2;j+=2)
                if(flag[j][0]==1&&flag[j][1]==1&&flag[j][2]==1)
                {
                    if(j==0)
                        printf("%c is the counterfeit coin and it is light.",x);
                    else
                        printf("%c is the counterfeit coin and it is heavy.",x);
                    cout<<endl;
                    print=1;
                }
            if(print==1)
                break;
        }   
    }
    return 0;
}



输不出正确答案,这是哪里有错
搜索更多相关主题的帖子: include status 
2015-01-16 18:44
wp231957
Rank: 20Rank: 20Rank: 20Rank: 20Rank: 20
来 自:神界
等 级:贵宾
威 望:423
帖 子:13688
专家分:53332
注 册:2012-10-18
收藏
得分:10 
不着头脑

DO IT YOURSELF !
2015-01-22 13:49
rjsp
Rank: 20Rank: 20Rank: 20Rank: 20Rank: 20
等 级:版主
威 望:528
帖 子:9025
专家分:54030
注 册:2011-1-18
收藏
得分:10 
如果你自己都懒得贴出 poj1013 的话
别人也一定懒得为了你的问题去网上查
2015-01-22 14:34
快速回复:poj1013
数据加载中...
 
   



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

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