编号 题目 状态 分数 总时间 内存 代码 / 答案文件 提交者 提交时间
#3798 #1008. 出行请佩戴好字符串 Compile Error 0 0 ms 0 K C++ 17 (Clang) / 744 B s230026047 2023-11-25 16:53:37
显示原始代码
#include <iostream>
#include <string>
#include <vector>
using namespace std;

int Date(string T, vector<string>& S);
int counter(string T, vector<string>& S);

int Date(string T, vector<string>& S) {
    for (int i = 0; i < N; i++) {
        if (S.length())==T[i].length()){
                if () {
                }
            }
        else {
        }
    }

    return i;
}
int counter(string T, vector<string>& S) {
    int count = 0;
    for (int i = 0; i < N; i++) {
        if (Date(T, S[i]) != 0) {
            count++;
        }
    }
    return count;
}

int main(int argc, char** argv) {
    int N, ans = 0;
    string St;
    cin >> N >> St;
    vector<string> Ts;
    for (int i = 0; i < N; i++) {
        cin >> T[i];
    }

    cout << count(St, Ts) << endl;
    for (int i = 0; i < N; i++) {
        cout << Date(St, Ts[i]) << endl;
    }

    return 0;
}

编译信息

/sandbox/1/a.cpp:10:18: error: use of undeclared identifier 'N'
        for (int i=0; i<N; i++){
                        ^
/sandbox/1/a.cpp:11:9: error: no member named 'length' in 'std::vector<std::basic_string<char>>'
                if (S.length())==T[i].length()){
                    ~ ^
/sandbox/1/a.cpp:11:18: error: expected expression
                if (S.length())==T[i].length()){
                               ^
/sandbox/1/a.cpp:11:24: error: member reference base type '__gnu_cxx::__alloc_traits<std::allocator<char>, char>::value_type' (aka 'char') is not a structure or union
                if (S.length())==T[i].length()){
                                 ~~~~^~~~~~~
/sandbox/1/a.cpp:20:9: error: use of undeclared identifier 'i'
        return i;
               ^
/sandbox/1/a.cpp:24:18: error: use of undeclared identifier 'N'
        for (int i=0; i<N; i++){
                        ^
/sandbox/1/a.cpp:25:7: error: no matching function for call to 'Date'
                if (Date(T,S[i])!=0){
                    ^~~~
/sandbox/1/a.cpp:9:5: note: candidate function not viable: no known conversion from '__gnu_cxx::__alloc_traits<std::allocator<std::basic_string<char>>, std::basic_string<char>>::value_type' (aka 'std::basic_string<char>') to 'vector<std::string> &' (aka 'vector<basic_string<char>> &') for 2nd argument
int Date(string T, vector<string>& S){
    ^
/sandbox/1/a.cpp:39:8: error: use of undeclared identifier 'T'
                cin>>T[i];
                     ^
/sandbox/1/a.cpp:42:8: error: use of undeclared identifier 'count'
        cout<<count(St,Ts)<<endl;
              ^
/sandbox/1/a.cpp:44:9: error: no matching function for call to 'Date'
                cout<<Date(St,Ts[i])<<endl;
                      ^~~~
/sandbox/1/a.cpp:9:5: note: candidate function not viable: no known conversion from '__gnu_cxx::__alloc_traits<std::allocator<std::basic_string<char>>, std::basic_string<char>>::value_type' (aka 'std::basic_string<char>') to 'vector<std::string> &' (aka 'vector<basic_string<char>> &') for 2nd argument
int Date(string T, vector<string>& S){
    ^
10 errors generated.