The Fourth Dimension Space

枯叶北风寒,忽然年以残,念往昔,语默心酸。二十光阴无一物,韶光贱,寐难安; 不畏形影单,道途阻且慢,哪曲折,如渡飞湍。斩浪劈波酬壮志,同把酒,共言欢! -如梦令

POJ 3458-Colour Sequence 水题-类brute force算法

今天晚上都是水题,直接上代码吧;

#include<iostream>
#include
<cmath>
#include
<cstring>
#include
<algorithm>
using namespace std;

char up[2000];
char down[2000];
char origin[2000];


int main ()
{

    
int n;
    
int i;
    
int pos1;
    
int pos2;
    scanf(
"%d",&n);
    
for(i=1;i<=n;i++)
    
{

        scanf(
"%s%s%s",origin,up,down);
        pos1
=0;
        pos2
=0;
        
int len=strlen(up);
        
while(1)

        
{
            
if(up[pos2]=='*'||down[pos2]=='*')
            
{
                pos2
++;
                pos1
++;
    
            }

            
else if(origin[pos1]==up[pos2]||origin[pos1]==down[pos2])
            
{
                pos2
++;
                pos1
++;
            }

            
else 
                pos2
++;

            
if(pos1==strlen(origin))
            
{
                printf(
"win\n");
                
break;
            }

            
if(pos2>len)
            
{
                printf(
"lose\n");
                
break;
            }

            
        }

    }

    system(
"pause");
    
return 0;
}

posted on 2009-03-06 23:06 abilitytao 阅读(851) 评论(0)  编辑 收藏 引用


只有注册用户登录后才能发表评论。
【推荐】超50万行VC++源码: 大型组态工控、电力仿真CAD与GIS源码库
网站导航: 博客园   IT新闻   BlogJava   知识库   博问   管理