滑稽


私信TA

用户名:252259947

访问量:16725

签 名:

等  级
排  名 91
经  验 8503
参赛次数 14
文章发表 26
年  龄 23
在职情况 教师
学  校 河北科技师范学院
专  业 计算机科学与技术

  自我简介:

解题思路:模拟

注意事项:

参考代码:

#include<stdio.h>
#include<string.h>
int main()
{
    char map[51][51],s[1001];
    int t,n,m,i,j,len,x,y,sx,sy;
    scanf("%d",&t);
    while(t--)
    {
        scanf("%d\n",&n);
        for(i=0;i<n;i++)
        {
            gets(map[i]);
            for(j=0;j<n;j++)
            {
                if(map[i][j]=='S')
                {
                    sx=i;
                    sy=j;
                }
            }
        }
        scanf("%d\n",&m);
        while(m--)
        {
            gets(s);
            len=strlen(s);
            x=sx;
            y=sy;
            for(i=0;i<len;i++)
            {
                if(s[i]=='U')
                    x--;
                else if(s[i]=='L')
                    y--;
                else if(s[i]=='D')
                    x++;
                else if(s[i]=='R')
                    y++;

                if(x<0||x>=n||y<0||y>=n)
                {
                    printf("I am out!\n");
                    break;
                }else if(map[x][y]=='#'){
                    printf("I am dizzy!\n");
                    break;
                }else if(map[x][y]=='T'){
                    printf("I get there!\n");
                    break;
                }
            }
            if(i==len)
                printf("I have no idea!\n");
        }
    }
    return 0;
}


 

0.0分

1 人评分

  评论区

if(i==len)
                printf("I have no idea!\n");
啥意思?
2021-03-15 20:59:10
  • «
  • 1
  • »