Language: C++

#include <iostream>
#include <string>
#include <algorithm>
 
using namespace std;
 
int main(){
  int a,b;
  int count=0;
  string s,reverse_s;
  cin>>a;
  cin>>b;
  for(int i=a;i<=b;i++){
    s=to_string(i);
    reverse_s=reverse(s.begin(),s.end());
    if(s==reverse_s){
      count+=1;
    }
  }
  cout<<count<<endl;
  return 0;
}
#include <iostream>
#include <string>
#include <algorithm>
 
using namespace std;
 
int main(){
  int a,b;
  int count=0;
  string s,reverse_s;
  cin>>a;
  cin>>b;
  for(int i=a;i<=b;i++){
    s=to_string(i);
    saved=copy(s);
    if(saved==reverse(s.begin(),s.end())){
      count+=1;
    }
  }
  cout<<count<<endl;
  return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:15:40: error: no match for 'operator=' (operand types are 'std::string' {aka 'std::__cxx11::basic_string<char>'} and 'void')
   15 |     reverse_s=reverse(s.begin(),s.end());
      |                                        ^
In file included from /usr/include/c++/14/string:54,
                 from /usr/include/c++/14/bits/locale_classes.h:40,
                 from /usr/include/c++/14/bits/ios_base.h:41,
                 from /usr/include/c++/14/ios:44,
                 from /usr/include/c++/14/ostream:40,
                 from /usr/include/c++/14/iostream:41,
                 from a.cc:1:
/usr/include/c++/14/bits/basic_string.h:941:8: note: candidate: 'template<class _Tp> std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::_If_sv<_Tp, std::__cxx11::basic_string<_CharT, _Traits, _Alloc>&> std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::operator=(const _Tp&) [with _CharT = char; _Traits = std::char_traits<char>; _Alloc = std::allocator<char>]'
  941 |        operator=(const _Tp& __svt)
      |        ^~~~~~~~
/usr/include/c++/14/bits/basic_string.h:941:8: note:   template argument deduction/substitution failed:
/usr/include/c++/14/bits/basic_string.h: In substitution of 'template<class _CharT, class _Traits, class _Alloc> template<class _Tp, class _Res> using std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::_If_sv = std::enable_if_t<((bool)std::__and_<std::is_convertible<const _Tp&, std::basic_string_view<_CharT, _Traits> >, std::__not_<std::is_convertible<const _Tp*, const std::__cxx11::basic_string<_CharT, _Traits, _Alloc>*> >, std::__not_<std::is_convertible<const _Tp&, const _CharT*> > >::value), _Res> [with _Tp = void; _Res = std::__cxx11::basic_string<char>&; _CharT = char; _Traits = std::char_traits<char>; _Alloc = std::allocator<char>]':
/usr/include/c++/14/bits/basic_string.h:941:8:   required by substitution of 'template<class _Tp> std::__cxx11::basic_string<char>::_If_sv<_Tp, std::__cxx11::basic_string<char>&> std::__cxx11::basic_string<char>::operator=(const _Tp&) [with _Tp = void]'
a.cc:15:40:   required from here
   15 |     reverse_s=reverse(s.begin(),s.end());
      |                                        ^
/usr/include/c++/14/bits/basic_string.h:152:70: error: forming reference to void
  152 |                  __not_<is_convertible<const _Tp&, const _CharT*>>>::value,
      |                                                                      ^~~~~
/usr/include/c++/14/bits/basic_string.h:817:7: note: candidate: 'std::__cxx11::basic_string<_CharT, _Traits, _Alloc>& std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::operator=(const std::__cxx11::basic_string<_CharT, _Traits, _Alloc>&) [with _CharT = char; _Traits = std::char_traits<char>; _Alloc = std::allocator<char>]'
  817 |       operator=(const basic_string& __str)
      |       ^~~~~~~~
/usr/include/c++/14/bits/basic_string.h:817:37: note:   no known conversion for argument 1 from 'void' to 'const std::__cxx11::basic_string<char>&'
  817 |       operator=(const basic_string& __str)
      |                 ~~~~~~~~~~~~~~~~~~~~^~~~~
/usr/include/c++/14/bits/basic_string.h:828:7: note: candidate: 'std::__cxx11::basic_string<_CharT, _Traits, _Alloc>& std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::operator=(const _CharT*) [with _CharT = char; _Traits = std::char_traits<char>; _Alloc = std::allocator<char>]'
  828 |       operator=(const _CharT* __s)
      |       ^~~~~~~~
/usr/include/c++/14/bits/basic_string.h:828:31: note:   no known conversion for argument 1 from 'void' to 'const char*'
  828 |       operator=(const _CharT* __s)
      |                 ~~~~~~~~~~~~~~^~~
/usr/include/c++/14/bits/basic_string.h:840:7: note: candidate: 'std::__cxx11::basic_string<_CharT, _Traits, _Alloc>& std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::operator=(_CharT) [with _CharT = char; _Traits = std::char_traits<char>; _Alloc = std::allocator<char>]'
  840 |       operator=(_CharT __c)
      |       ^~~~~~~~
/usr/include/c++/14/bits/basic_string.h:840:24: note:   no known conversion for argument 1 from 'void' to 'char'
  840 |       operator=(_CharT __c)
      |                 ~~~~~~~^~~
/usr/include/c++/14/bits/basic_string.h:858:7: note: candidate: 'std::__cxx11::basic_string<_CharT, _Traits, _Alloc>& std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::operator=(std::__cxx11::basic_string<_CharT, _Traits, _Alloc>&&) [with _CharT = char; _Traits = std::char_traits<char>; _Alloc = std::allocator<char>]'
  858 |       operator=(basic_string&& __str)
      |       ^~~~~~~~
/usr/include/c++/14/bits/basic_string.h:858:32: note:   no known conversion for argument 1 from 'void' to 'std::__cxx11::basic_string<char>&&'
  858 |       operator=(basic_string&& __str)
      |                 ~~~~~~~~~~~~~~~^~~~~
/usr/include/c++/14/bits/basic_string.h:926:7: note: candidate: 'std::__cxx11::basic_string<_CharT, _Traits, _Alloc>& std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::operator=(std::initializer_list<_Tp>) [with _CharT = char; _Traits = std::char_traits<char>; _Alloc = std::allocator<char>]'
  926 |       operator=(initializer_list<_CharT> __l)
      |       ^~~~~~~~
/usr/include/c++/14/bits/basic_string.h:926:42: note:   no known conversion for argument 1 from 'void' to 'std::initializer_list<char>'
  926 |       operator=(initializer_list<_CharT> __l)
      |                 ~~~~~~~~~~~~~~~~~~~~~~~~~^~~
a.cc: At global scope:
a.cc:29:5: error: redefinition of 'int main()'
   29 | int main(){
      |     ^~~~
a.cc:7:5: note: 'int main()' previously defined here
    7 | int main(){
      |     ^~~~
a.cc: In function 'int main()':
a.cc:37:5: error: 'saved' was not declared in this scope
   37 |     saved=copy(s);
      |     ^~~~~
a.cc:37:15: error: no matching function for call to 'copy(std::string&)'
   37 |     saved=copy(s);
      |           ~~~~^~~
In file included from /usr/include/c++/14/string:51:
/usr/include/c++/14/bits/stl_algobase.h:642:5: note: candidate: 'template<class _II, class _OI> _OI std::copy(_II, _II, _OI)'
  642 |     copy(_II __first, _II __last, _OI __result)
      |     ^~~~
/usr/include/c++/14/bits/stl_algobase.h:642:5: note:   candidate expects 3 arguments, 1 provided
In file included from /usr/include/c++/14/bits/locale_facets.h:48,
                 from /usr/include/c++/14/bits/basic_ios.h:37,
                 from /usr/include/c++/14/ios:46:
/usr/include/c++/14/bits/streambuf_iterator.h:339:5: note: candidate: 'template<class _CharT> typename __gnu_cxx::__enable_if<std::__is_char<_Tp>::__value, std::ostreambuf_iterator<_CharT> >::__type std::copy(istreambuf_iterator<_CharT>, istreambuf_iterator<_CharT>, ostreambuf_iterator<_CharT>)'
  339 |     copy(istreambuf_iterator<_CharT> __first,
      |     ^~~~
/usr/include/c++/14/bits/streambuf_iterator.h:339:5: note:   candidate expects 3 arguments, 1 provided
In file included from /usr/include/c++/14/algorithm:86,
                 from a.cc:3:
/usr/include/c++/14/pstl/glue_algorithm_defs.h:134:1: note: candidate: 'template<class _ExecutionPolicy, class _ForwardIterator1, class _ForwardIterator2> __pstl::__internal::__enable_if_execution_policy<_ExecutionPolicy, _ForwardIterator2> std::copy(_ExecutionPolicy&&, _ForwardIterator1, _ForwardIterator1, _ForwardIterator2)'
  134 | copy(_ExecutionPolicy&& __exec, _ForwardIterator1 __first, _ForwardIterator1 __last, _ForwardIterator2 __result);
      | ^~~~
/usr/include/c++/14/pstl/glue_algorithm_defs.h:134:1: note:   candidate expects 4 arguments, 1 provided