zoukankan      html  css  js  c++  java
  • U147730 Get Your Wish

    Aimee

    很水的题目

    #include<iostream>
    #include<cstdio>
    #include<algorithm> 
    #include<cstring>
    using namespace std;
    int mx[5]={0,1,-1,0,0};
    int my[5]={0,0,0,-1,1};
    int n,m;
    char ma[101][101];
    char im;
    int Aimee;
    struct wa{
    	int l;int r;
    }jdn[1001];
    int p;
    void dfs(int x,int y){
    	if(ma[x][y]=='x'){
    		cout<<"GG";
    		exit(0);
    	}
    	if(ma[x][y]!='.'&&ma[x][y]!='o'){
    		return ;
    	}
    	dfs(x+mx[Aimee],y+my[Aimee]);
    	return ; 
    }
    int main(){
    	scanf("%d%d",&n,&m);
    	cin>>im;
    	if(im=='^'){
    		Aimee=2;
    	}
    	if(im=='v'){
    		Aimee=1;
    	}
    	if(im=='<'){
    		Aimee=3;
    	}
    	if(im=='>'){
    		Aimee=4;
    	}
    	for(int i=1;i<=n;++i){
    		for(int j=1;j<=m;++j){
    			cin>>ma[i][j];
    			if(ma[i][j]=='o'){
    				p++;
    				jdn[p].l=i;
    				jdn[p].r=j;
    			}
    		}
    	}
    	for(int i=1;i<=p;++i){
    		dfs(jdn[i].l,jdn[i].r);
    	}
    	cout<<"OK";
    	return 0;
    }
    
  • 相关阅读:
    遍历二维数组
    冒泡跟扫描共用
    1.8作业
    1.7作业
    1.5作业
    百文百鸡 水仙花数 百马百担
    for循环输出九九乘法表
    循环语句
    1.4作业
    07、找出1-99之间的同构数
  • 原文地址:https://www.cnblogs.com/For-Miku/p/14258969.html
Copyright © 2011-2022 走看看