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

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;
}

你可能感兴趣的:(POJ 3458-Colour Sequence 水题-类brute force算法)