include
include
include
using namespace std;
//This is solution to the problem 41A //Please help
int main() { string s1; string s2; char user[]={}; char arr[]={}; cin >> s1; unsigned int last; last = s1.length() — 1 ;
for(int j = 0;j<s1.length();j++) { cin >> user[j]; } int counter; for (int q = 0;q<s1.length();q++) { if(user[q]==s1[last - q]) { counter = counter + 1; } } if (counter == s1.length()) { cout << "YES"<< endl; } else { cout << "NO"<< endl; } //cout << counter;
}
counter
isn't initialized to any value.That will give you a garbage value, but won't throw an error.
CF explicitly tells you what the issue is: out of bounds
You are trying to take input in $$$user[j]$$$ but the array $$$user$$$ does not have the index $$$j$$$, that is, $$$j \ge size\_of\_user$$$.
Can you please elaborate ?
What is the size of the $$$user$$$ array?