Language: C++

#include<bits/stdc++.h>
using namespace std;
 
 
 
 
 int main()
 {
   string str=""
 string a,b;
   cin>>a>>b;
   int sa=a.length();
   int sb=b.length();
  int dp[sb+1][sa+1];
   for(int i=0;i<sa+1;i++)
     dp[0][i]=0;
     for(int i=0;i<sb+1;i++)
     dp[i][0]=0;
   for(int i=1;i<sb+1;i++)
   for(int j=1;j<sa+1;j++)
   {  
     if(b[i-1]==a[j-1])
     {
       dp[i][j]=1+dp[i-1][j-1];
       str+=dp[i-1];
     }
     else
       dp[i][j]=max(dp[i-1][j],dp[i][j-1]); 
   }
   return str;
   
   
 
 }

Compiler output:
a.cc: In function 'int main()':
a.cc:10:2: error: expected ',' or ';' before 'string'
   10 |  string a,b;
      |  ^~~~~~
a.cc:11:9: error: 'a' was not declared in this scope
   11 |    cin>>a>>b;
      |         ^
a.cc:11:12: error: 'b' was not declared in this scope
   11 |    cin>>a>>b;
      |            ^
a.cc:25:11: error: no match for 'operator+=' (operand types are 'std::string' {aka 'std::__cxx11::basic_string<char>'} and 'int [(sa + 1)]')
   25 |        str+=dp[i-1];
      |        ~~~^~~~~~~~~
In file included from /usr/include/c++/14/string:54,
                 from /usr/include/c++/14/bitset:52,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:52,
                 from a.cc:1:
/usr/include/c++/14/bits/basic_string.h:1397: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>]' (near match)
 1397 |       operator+=(_CharT __c)
      |       ^~~~~~~~
/usr/include/c++/14/bits/basic_string.h:1397:7: note:   conversion of argument 1 would be ill-formed:
a.cc:25:19: error: invalid conversion from 'int*' to 'char' [-fpermissive]
   25 |        str+=dp[i-1];
      |             ~~~~~~^
      |                   |
      |                   int*
/usr/include/c++/14/bits/basic_string.h:1424:9: 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>]'
 1424 |         operator+=(const _Tp& __svt)
      |         ^~~~~~~~
/usr/include/c++/14/bits/basic_string.h:1424:9: note:   template argument deduction/substitution failed:
a.cc:25:19: note:   variable-sized array type 'int [(sa + 1)]' is not a valid template argument
   25 |        str+=dp[i-1];
      |                   ^
/usr/include/c++/14/bits/basic_string.h:1377: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>]'
 1377 |       operator+=(const basic_string& __str)
      |       ^~~~~~~~
/usr/include/c++/14/bits/basic_string.h:1377:38: note:   no known conversion for argument 1 from 'int [(sa + 1)]' to 'const std::__cxx11::basic_string<char>&'
 1377 |       operator+=(const basic_string& __str)
      |                  ~~~~~~~~~~~~~~~~~~~~^~~~~
/usr/include/c++/14/bits/basic_string.h:1387: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>]'
 1387 |       operator+=(const _CharT* __s)
      |       ^~~~~~~~
/usr/include/c++/14/bits/basic_string.h:1387:32: note:   no known conversion for argument 1 from 'int [(sa + 1)]' to 'const char*'
 1387 |       operator+=(const _CharT* __s)
      |                  ~~~~~~~~~~~~~~^~~
/usr/include/c++/14/bits/basic_string.h:1411: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>]'
 1411 |       operator+=(initializer_list<_CharT> __l)
      |       ^~~~~~~~
/usr/include/c++/14/bits/basic_string.h:1411:43: note:   no known conversion for argument 1 from 'int [(sa + 1)]' to 'std::initializer_list<char>'
 1411 |       operator+=(initializer_list<_CharT> __l)
      |                  ~~~~~~~~~~~~~~~~~~~~~~~~~^~~
a.cc:30:11: error: cannot convert 'std::string' {aka 'std::__cxx11::basic_string<char>'} to 'int' in return
   30 |    return str;
      |           ^~~
      |           |
      |           std::string {aka std::__cxx11::basic_string<char>}