编号 题目 状态 分数 总时间 内存 代码 / 答案文件 提交者 提交时间
#5940 #1056. 移动路线 Compile Error 0 0 ms 0 K C++ 17 / 1.2 K t330034024 2024-08-17 17:52:01
显示原始代码
#include <iostream>
#include <string>

using namespace std;

string determineDirection(const string& instructions) {
    int x = 0, y = 0;
    int x1 = 0, y1 = 0;
    for (int i = 0; i < instructions.size() / 4; ++i) {
        char dir = instructions[i];
        switch (dir) {
            case 'N':
                y++;
                break;
            case 'E':
                x++;
                break;
            case 'S':
                y--;
                break;
            case 'W':
                x--;
                break;
        }
    }
    for (int i = instructions.size() / 4; i < instructions.size() / 2; ++i) {
        char dir = instructions[i];
        switch (dir) {
            case 'N':
                y1++;
                break;
            case 'E':
                x1++;
                break;
            case 'S':
                y1--;
                break;
            case 'W':
                x1--;
                break;
        }
    }
    if ((x >= 0 && y >= 0 && x1 >= 0 && y1 <= 0) || (x >= 0 && y < 0 && x1 < 0 && y1 < 0) ||
        (x < 0 && y < 0 && x1 <= 0 && y1 > 0) || (x < 0 && y > 0 && x1 > 0 && y1 > 0))
        return "CW";
    // else if (north < south && east > west)
    return "CCW";
}

int main() {
    int T;
    cin >> T;

    while (T--) {
        string instructions;
        cin >> instructions;
        cout << determineDirection(instructions);
        if (T)
            cout <<“ ”;
    }
    return 0;
}

编译信息

/sandbox/1/a.cpp:47:23: error: extended character “ is not valid in an identifier
   47 |         if (T) cout <<�� ”;
      |                       ^
/sandbox/1/a.cpp:47:27: error: extended character ” is not valid in an identifier
   47 |         if (T) cout <<“ ��;
      |                         ^
/sandbox/1/a.cpp: In function 'int main()':
/sandbox/1/a.cpp:47:23: error: '\U0000201c' was not declared in this scope
   47 |         if (T) cout << ”;
      |                       ^