Answer to Question #264546 in Python for swsq

Question #264546
  1. Reverse a string and calculate unchanged positions to the original string? 
1
Expert's answer
2021-11-21T04:55:05-0500
#include <bits/stdc++.h>
using namespace std;


int main()
{
  string s, ss;
  int cnt = 0;
  cout << "Input string: ";
  cin >> s;
  ss = s;
  reverse(ss.begin(), ss.end());
  
  for (int i = 0; i < s.size(); i++) {
    if (ss[i] == s[i]) cnt++;
  }
  cout << "Answer: " << cnt << '\n';


  return 0;
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS