报错:
./Main.cpp:9:25: error: use of undeclared identifier 'a'
memset(a, 0, sizeof(a));
^
./Main.cpp:9:12: error: use of undeclared identifier 'a'
memset(a, 0, sizeof(a));
^
2 errors generated.
代码:
#include <iostream>
#include <cstring>
#include <cstdio>
using namespace std;
int main() {
int n, m;
string s;
int v = 0;
memset(a, 0, sizeof(a));
cin >> n >> m >> s;
int a[m];
int x[m], y[m];
for (int i = 0; i < m; i++) {
cin >> x[i] >> y[i];
}
int q = 1;
for (int i = 0; i < m; i++) {
for (int j = x[i]; j <= y[i]; j++) {
while (s[j] == 'A' && s[j + 1] == 'C') {
a[i]++;
j++;
}
cout << a[i] << endl;
}
}
return 0;
}