44122023-03-27 18:39:12balaaaazsŐsi szövegcpp14Forditási hiba
int main() {
    int N, K;
    cin >> N >> K;
    vector<string> S(N);
    for (int i = 0; i < N; i++) {
        cin >> S[i];
    }
    
    vector<vector<int>> dist(N, vector<int>(N, 0));
    for (int i = 0; i < N; i++) {
        for (int j = i + 1; j < N; j++) {
            int d = 0;
            for (int k = 0; k < K; k++) {
                if (S[i][k] != S[j][k]) {
                    d++;
                }
            }
            dist[i][j] = d;
            dist[j][i] = d;
        }
    }
    
    vector<double> avgdist(N, 0.0);
    double divisor = N - 1;
    for (int i = 0; i < N; i++) {
        for (int j = 0; j < N; j++) {
            if (i != j) {
                avgdist[i] += dist[i][j];
            }
        }
        avgdist[i] /= divisor;
    }
    
    int min_index = min_element(avgdist.begin(), avgdist.end()) - avgdist.begin();
    cout << min_index << endl;
    
    return 0;
}
Forditási hiba
exit status 1
main.cpp: In function 'int main()':
main.cpp:3:5: error: 'cin' was not declared in this scope
    3 |     cin >> N >> K;
      |     ^~~
main.cpp:4:5: error: 'vector' was not declared in this scope
    4 |     vector<string> S(N);
      |     ^~~~~~
main.cpp:4:12: error: 'string' was not declared in this scope
    4 |     vector<string> S(N);
      |            ^~~~~~
main.cpp:4:20: error: 'S' was not declared in this scope
    4 |     vector<string> S(N);
      |                    ^
main.cpp:9:19: error: expected primary-expression before 'int'
    9 |     vector<vector<int>> dist(N, vector<int>(N, 0));
      |                   ^~~
main.cpp:18:13: error: 'dist' was not declared in this scope
   18 |             dist[i][j] = d;
      |             ^~~~
main.cpp:23:12: error: expected primary-expression before 'double'
   23 |     vector<double> avgdist(N, 0.0);
      |            ^~~~~~
main.cpp:28:17: error: 'avgdist' was not declared in this scope
   28 |                 avgdist[i] += dist[i][j];
      |...