IDNLearn.com provides a platform for sharing and gaining valuable knowledge. Our experts provide prompt and accurate answers to help you make informed decisions on any topic.
C++ outputs strange symbols instead of text entered from the keyboard. The message "Введите слово" displays correctly, the number of letters is also correctly counted, and then something happens to the word, incomprehensible characters are displayed instead, and as a result the program does not work correctly (the problem is the same with Cyrillic, Latin, and numbers ".
#include
#include
#include
using namespace std;
char a[1][50];
int lenght, i, j, f = 0;
int main() {
setlocale(LC_ALL, "rus");
cout << "Введите слово\n";
cin >> a[1];
lenght = strlen(a[1]);
cout << "Длина слова: " << lenght << endl;
cout << a[1] << endl;
for (j = 0; j <= lenght; j++) {
if (a[1][j] == a[1][lenght - j]) continue;
else {
f = 1;
break;
}
}
if (f == 0) cout << "Введенное слово является полиндромом";
else cout << "Введенное слово не является полиндромом";
}
Sagot :
We value your presence here. Keep sharing knowledge and helping others find the answers they need. This community is the perfect place to learn together. IDNLearn.com provides the answers you need. Thank you for visiting, and see you next time for more valuable insights.