QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#323813#5577. Alchemythanhha1210Compile Error//C++14572b2024-02-10 13:32:312024-02-10 13:32:32

Judging History

你现在查看的是最新测评结果

  • [2024-02-10 13:32:32]
  • 评测
  • [2024-02-10 13:32:31]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;

int main() {
    string s;
    cin >> s;
    int len = s.length();
    int cnt = 0;

    int i = 0, j = len - 1;
    while (i < j) {
        if (s[i] == s[j]) {
            i++;
            j--;
        }

        else (s[i] != s[j]) {
            if (j == i + 1) {
                cnt += 1;
                j--;
                i++;
            }
            else {
                cnt += 2;
                j-= 2;
                i+= 2;
            }
        }
    }
    cout << cnt << endl;
}

Details

answer.code: In function ‘int main()’:
answer.code:17:28: error: expected ‘;’ before ‘{’ token
   17 |         else (s[i] != s[j]) {
      |                            ^~
      |                            ;