Language: C++

#include<bits/stdc++.h>
using namespace std;

int main(){
    int n;
    while(cin>>n,n){
        vector<string> str(n);
        for(int i=0;i<n;i++){
            cin>>str[i];
        }
        vector<string> res(n);
        for(int i=0;i<n;i++){
            res[i].assign(str[i].size());
            int dotcnt=0;
            for(int j=str[i].size()-1;j>=0;j--){
                if(str[i][j]=='.'){
                    if(dotcnt==0){
                        res[i][j]='+';
                    }
                    else{
                        res[i][j]=' ';
                    }
                    dotcnt++;
                }
                else{
                    res[i][j]=str[i][j];
                }
            }
        }

        for(int j=0;j<10000;j++){
            int tail=0;
            bool plus=false;
            for(int i=0;i<n;i++){
                if(j>=res[i].size()){
                    plus=false;
                    continue;
                }
                if(res[i][j]=='+'){
                   if(plus){
                       for(tail++;tail<i;tail++){
                           res[tail][j]='|';
                       }
                   } 
                   else{
                        plus=true;
                        tail=i;
                   }
                }
                else if(res[i][j]!=' '){
                    plus=false;
                }
                
            }
        }
        for(int i=0;i<n;i++) cout<<res[i]<<endl;
    }
    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:13:26: error: no matching function for call to 'std::__cxx11::basic_string<char>::assign(std::__cxx11::basic_string<char>::size_type)'
   13 |             res[i].assign(str[i].size());
      |             ~~~~~~~~~~~~~^~~~~~~~~~~~~~~
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:1692:7: note: candidate: 'std::__cxx11::basic_string<_CharT, _Traits, _Alloc>& std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::assign(const _CharT*) [with _CharT = char; _Traits = std::char_traits<char>; _Alloc = std::allocator<char>]' (near match)
 1692 |       assign(const _CharT* __s)
      |       ^~~~~~
/usr/include/c++/14/bits/basic_string.h:1692:7: note:   conversion of argument 1 would be ill-formed:
a.cc:13:38: error: invalid conversion from 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} to 'const char*' [-fpermissive]
   13 |             res[i].assign(str[i].size());
      |                           ~~~~~~~~~~~^~
      |                                      |
      |                                      std::__cxx11::basic_string<char>::size_type {aka long unsigned int}
/usr/include/c++/14/bits/basic_string.h:1728:9: note: candidate: 'template<class _InputIterator, class> std::__cxx11::basic_string<_CharT, _Traits, _Alloc>& std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::assign(_InputIterator, _InputIterator) [with <template-parameter-2-2> = _InputIterator; _CharT = char; _Traits = std::char_traits<char>; _Alloc = std::allocator<char>]'
 1728 |         assign(_InputIterator __first, _InputIterator __last)
      |         ^~~~~~
/usr/include/c++/14/bits/basic_string.h:1728:9: note:   candidate expects 2 arguments, 1 provided
/usr/include/c++/14/bits/basic_string.h:1787: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>::assign(const _Tp&) [with _CharT = char; _Traits = std::char_traits<char>; _Alloc = std::allocator<char>]'
 1787 |         assign(const _Tp& __svt)
      |         ^~~~~~
/usr/include/c++/14/bits/basic_string.h:1787:9: note:   template argument deduction/substitution failed:
In file included from /usr/include/c++/14/bits/stl_pair.h:60,
                 from /usr/include/c++/14/bits/stl_algobase.h:64,
                 from /usr/include/c++/14/algorithm:60,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51:
/usr/include/c++/14/type_traits: In substitution of 'template<bool _Cond, class _Tp> using std::enable_if_t = typename std::enable_if::type [with bool _Cond = false; _Tp = std::__cxx11::basic_string<char>&]':
/usr/include/c++/14/bits/basic_string.h:149:8:   required by 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 = long unsigned int; _Res = std::__cxx11::basic_string<char>&; _CharT = char; _Traits = std::char_traits<char>; _Alloc = std::allocator<char>]'
  149 |         using _If_sv = enable_if_t<
      |               ^~~~~~
/usr/include/c++/14/bits/basic_string.h:1787:2:   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>::assign(const _Tp&) [with _Tp = long unsigned int]'
 1787 |         assign(const _Tp& __svt)
      |         ^~~~~~
a.cc:13:26:   required from here
   13 |             res[i].assign(str[i].size());
      |             ~~~~~~~~~~~~~^~~~~~~~~~~~~~~
/usr/include/c++/14/type_traits:2711:11: error: no type named 'type' in 'struct std::enable_if<false, std::__cxx11::basic_string<char>&>'
 2711 |     using enable_if_t = typename enable_if<_Cond, _Tp>::type;
      |           ^~~~~~~~~~~
/usr/include/c++/14/bits/basic_string.h:1803: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>::assign(const _Tp&, size_type, size_type) [with _CharT = char; _Traits = std::char_traits<char>; _Alloc = std::allocator<char>]'
 1803 |         assign(const _Tp& __svt, size_type __pos, size_type __n = npos)
      |         ^~~~~~
/usr/include/c++/14/bits/basic_string.h:1803:9: note:   candidate expects 2 arguments, 1 provided
/usr/include/c++/14/bits/basic_string.h:1588:7: note: candidate: 'std::__cxx11::basic_string<_CharT, _Traits, _Alloc>& std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::assign(const std::__cxx11::basic_string<_CharT, _Traits, _Alloc>&) [with _CharT = char; _Traits = std::char_traits<char>; _Alloc = std::allocator<char>]'
 1588 |       assign(const basic_string& __str)
      |       ^~~~~~
/usr/include/c++/14/bits/basic_string.h:1588:34: note:   no known conversion for argument 1 from 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} to 'const std::__cxx11::basic_string<char>&'
 1588 |       assign(const basic_string& __str)
      |              ~~~~~~~~~~~~~~~~~~~~^~~~~
/usr/include/c++/14/bits/basic_string.h:1634:7: note: candidate: 'std::__cxx11::basic_string<_CharT, _Traits, _Alloc>& std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::assign(std::__cxx11::basic_string<_CharT, _Traits, _Alloc>&&) [with _CharT = char; _Traits = std::char_traits<char>; _Alloc = std::allocator<char>]'
 1634 |       assign(basic_string&& __str)
      |       ^~~~~~
/usr/include/c++/14/bits/basic_string.h:1634:29: note:   no known conversion for argument 1 from 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} to 'std::__cxx11::basic_string<char>&&'
 1634 |       assign(basic_string&& __str)
      |              ~~~~~~~~~~~~~~~^~~~~
/usr/include/c++/14/bits/basic_string.h:1658:7: note: candidate: 'std::__cxx11::basic_string<_CharT, _Traits, _Alloc>& std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::assign(const std::__cxx11::basic_string<_CharT, _Traits, _Alloc>&, size_type, size_type) [with _CharT = char; _Traits = std::char_traits<char>; _Alloc = std::allocator<char>; size_type = long unsigned int]'
 1658 |       assign(const basic_string& __str, size_type __pos, size_type __n = npos)
      |       ^~~~~~
/usr/include/c++/14/bits/basic_string.h:1658:7: note:   candidate expects 3 arguments, 1 provided
/usr/include/c++/14/bits/basic_string.h:1675:7: note: candidate: 'std::__cxx11::basic_string<_CharT, _Traits, _Alloc>& std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::assign(const _CharT*, size_type) [with _CharT = char; _Traits = std::char_traits<char>; _Alloc = std::allocator<char>; size_type = long unsigned int]'
 1675 |       assign(const _CharT* __s, size_type __n)
      |       ^~~~~~
/usr/include/c++/14/bits/basic_string.h:1675:7: note:   candidate expects 2 arguments, 1 provided
/usr/include/c++/14/bits/basic_string.h:1710:7: note: candidate: 'std::__cxx11::basic_string<_CharT, _Traits, _Alloc>& std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::assign(size_type, _CharT) [with _CharT = char; _Traits = std::char_traits<char>; _Alloc = std::allocator<char>; size_type = long unsigned int]'
 1710 |       assign(size_type __n, _CharT __c)
      |       ^~~~~~
/usr/include/c++/14/bits/basic_string.h:1710:7: note:   candidate expects 2 arguments, 1 provided
/usr/include/c++/14/bits/basic_string.h:1761:7: note: candidate: 'std::__cxx11::basic_string<_CharT, _Traits, _Alloc>& std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::assign(std::initializer_list<_Tp>) [with _CharT = char; _Traits = std::char_traits<char>; _Alloc = std::allocator<char>]'
 1761 |       assign(initializer_list<_CharT> __l)
      |       ^~~~~~
/usr/include/c++/14/bits/basic_string.h:1761:39: note:   no known conversion for argument 1 from 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} to 'std::initializer_list<char>'
 1761 |       assign(initializer_list<_CharT> __l)
      |              ~~~~~~~~~~~~~~~~~~~~~~~~~^~~