编号 题目 状态 分数 总时间 内存 代码 / 答案文件 提交者 提交时间
#5020 #1030. 选择题 Compile Error 0 0 ms 0 K C++ 17 / 1.1 K t330026199 2024-02-25 15:02:13
显示原始代码
#include <iostream>
using namespace std;
int N;
const int manx = 10000 + 5;
char z_ans[manx][6];
char t_ans[manx][6];
int main() {
    cin >> N;
    for (int i = 1; i <= N; i++) {
        cin >> z_ans[i];
        cin >> t_ans[i];
    }
    // for(int i=1;i<=N;i++)
    // cout << z_ans[i] <<endl<< t_ans[i] << endl;
    int score = 0;
    for (int i = 1; i <= N; i++) {
        if (strlen(t_ans[i]) == 1) {
            if (z_ans[i][1] == t_ans[i][1])
                score += 3;
        } else {
            if (strlen(z_ans[i]) > strlen(t_ans[i]))
                score += 0;
            else {
                int mark = 0;
                for (int j = 0; j < strlen(z_ans[i]); j++) {
                    for (int k = 0; k < strlen(t_ans[i]); k++) {
                        if (z_ans[i][j] == t_ans[i][k]) {
                            // cout << z_ans[i][j] << endl << t_ans[i][k]<<endl;
                            mark++;
                            break;
                        }
                    }
                }
                //	cout  << mark << endl;
                if (mark == strlen(z_ans[i]) && mark == strlen(t_ans[i]))
                    score += 5;
                else if (mark == strlen(z_ans[i]))
                    score += 2;

                // cout << z_ans[1][0]<<z_ans[1][1]<<z_ans[1][2]<<z_ans[1][3];
                // cout << t_ans[1][0] << t_ans[1][1];
            }
        }
    }
    cout << score << endl;
    return 0;
}

编译信息

/sandbox/1/a.cpp: In function 'int main()':
/sandbox/1/a.cpp:17:7: error: 'strlen' was not declared in this scope
   17 |   if (strlen(t_ans[i]) == 1)
      |       ^~~~~~
/sandbox/1/a.cpp:2:1: note: 'strlen' is defined in header '<cstring>'; did you forget to '#include <cstring>'?
    1 | #include<iostream>
  +++ |+#include <cstring>
    2 | using namespace std;