题解 | #坐标移动#

坐标移动

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

#include <string.h>

int main()
{
    char str[10003]={0};
    int i,count=0,x=0,y=0;
    fgets(str, sizeof(str), stdin);
    for(i=0;i<10002;i++)
    {count++;
     if(str[i]==';')
     {
         switch(str[i-count+1])
         {
         case 65:
         {
             if(count==3&&48<=str[i-count+2]&&57>=str[i-count+2])
                 x=x-(str[i-count+2]-48);
          if(count==4&&48<=str[i-count+2]&&57>=str[i-count+2]&&48<=str[i-count+3]&&57>=str[i-count+3])
              x=x-(str[i-count+2]-48)*10- (str[i-count+3]-48);
          } 
         break;
         case 83:
         {
             if(count==3&&48<=str[i-count+2]&&57>=str[i-count+2])
                 y=y-(str[i-count+2]-48);
          if(count==4&&48<=str[i-count+2]&&57>=str[i-count+2]&&48<=str[i-count+3]&&57>=str[i-count+3])
              y=y-(str[i-count+2]-48)*10- (str[i-count+3]-48);
          } 
         break;
         case 87:
         {
             if(count==3&&48<=str[i-count+2]&&57>=str[i-count+2])
                 y=y+str[i-count+2]-48;
          if(count==4&&48<=str[i-count+2]&&57>=str[i-count+2]&&48<=str[i-count+3]&&57>=str[i-count+3])
              y=y+(str[i-count+2]-48)*10+ (str[i-count+3]-48);
          } 
         break;
         case 68:
         {
             if(count==3&&48<=str[i-count+2]&&57>=str[i-count+2])
                 x=x+str[i-count+2]-48;
          if(count==4&&48<=str[i-count+2]&&57>=str[i-count+2]&&48<=str[i-count+3]&&57>=str[i-count+3])
              x=x+(str[i-count+2]-48)*10+ (str[i-count+3]-48);
          } 
         break;
         default:
         break;
             }
         count=0;
         }
         
     }
    printf("%d,%d",x,y);
}
       

    

全部评论

相关推荐

昨天 21:05
门头沟学院 C++
lebron0101:感觉前端赢了好多次了
点赞 评论 收藏
分享
程序员小白条:学历GG,这个排版布局,还有行间距和字缩进不大行,女生自我要求应该更高才是,没内容,起码美观这块要做好
投了多少份简历才上岸
点赞 评论 收藏
分享
评论
1
1
分享

创作者周榜

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