坐标移动

坐标移动

http://www.nowcoder.com/questionTerminal/119bcca3befb405fbe58abe9c532eb29

#include <stdio.h>
#include <string.h>
int x = 0, y = 0;
void like(char* str)
{
    int num = strlen(str);
    if (num > 3 || num <= 1)
        return;
    else
    {
        if ((str[0] == 'A' && str[1] >= '0' && str[1] <= '9' && str[2] == 0) ||
            (str[0] == 'A' && str[1] >= '0' && str[1] <= '9' && str[2] >= '0' && str[2] <= '9'))
        {
            if (str[2])
                x = x - ((str[1] - '0') * 10 + str[2] - '0');
            else
                x = x - str[1] + '0';
        }

        if ((str[0] == 'D' && str[1] >= '0' && str[1] <= '9' && str[2] == 0) ||
            (str[0] == 'D' && str[1] >= '0' && str[1] <= '9' && str[2] >= '0' && str[2] <= '9'))
        {
            if (str[2])
                x = x + ((str[1] - '0') * 10 + str[2] - '0');
            else
                x = x + str[1] - '0';
        }

        if ((str[0] == 'S' && str[1] >= '0' && str[1] <= '9' && str[2] == 0) ||
            (str[0] == 'S' && str[1] >= '0' && str[1] <= '9' && str[2] >= '0' && str[2] <= '9'))
        {
            if (str[2])
                y = y - ((str[1] - '0') * 10 + str[2] - '0');
            else
                y = y - str[1] + '0';
        }

        if ((str[0] == 'W' && str[1] >= '0' && str[1] <= '9' && str[2] == 0) ||
            (str[0] == 'W' && str[1] >= '0' && str[1] <= '9' && str[2] >= '0' && str[2] <= '9'))
        {
            if (str[2])
                y = y + ((str[1] - '0') * 10 + str[2] - '0');
            else
                y = y + str[1] - '0';
        }
    }
}
int main(void)
{
    char str[10000];
    char str1[1000];
    while (scanf("%s", str) != EOF)
    {
        x = 0; y = 0;
        int num = strlen(str);
        int j = 0;
        for (int i = 0; i < num; i++)
        {
            if (str[i] == ';')
            {
                str1[j] = 0;
                like(str1);
                j = 0;
                continue;
            }
            str1[j] = str[i];
            j++;
        }
        printf("%d,%d\r\n", x, y);
    }
 
    return 0;
}

全部评论
复制到一个数组,不断复制,然后处理,
点赞 回复 分享
发布于 2021-08-05 08:08

相关推荐

点赞 评论 收藏
分享
大方的大熊猫准备进厂:1.教育背景:你希望从事什么专业的工作你的主修课就是什么;成绩优秀是你应该做的,没什么可描述的,成绩不优秀也许人家在大学忙着创业呢?(成绩优秀不一定是好事,只能说明多元化的大学你上成了高中,没有真正上明白大学,反而体现了你死板,不爱社交,没有别的突出能力) 2.实践经历:你想表达的意思没有说清楚。你是说你会个性化服务,还是你有实习经历。如果没有带来,经济收益,表彰,更好的发展前景,那你还不如说说提升了自己哪些技能。你说有人给你送锦旗我都能明白你优秀,但是你说你会xxxx,你说这话谁信,证据呢。 3.入伍经历:你描述的就是你的工作职责或者你应该做的,并没有体现出来你把这个事情做好了,而且入伍经历并不能证明你能干好你要应聘的工作,不如只写经历其余所有内容都不写。 4.荣誉技能:重点突出一下,但不要过多描述,这些荣誉的含金量懂得都懂。 重点:你要应聘什么工作(具体岗位,实习生不具体),你的期望薪资
点赞 评论 收藏
分享
评论
8
1
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务