Am facut ambele modificari si acum obtin alte erori de compilare. Iata codul:
#include <fstream>
#define NMAX 1025
using namespace std;
ifstream fin("cmlsc.in");
ofstream fout("cmlsc.out");
int m,n,i,max,a[NMAX],b[NMAX],sol[NMAX],poz=1,j,loc,k;
void citire()
{ fin>>m>>n;
for (i=1; i<=m; i++) fin>>a[i];
for (i=1; i<=n; i++) fin>>b[i];
}
int solutie(int i, int j)
{ if (i==m+1 && j==n+1) return max;
else if (a[i]==b[j]) { max++; sol[poz]=a[i]; poz++; solutie(i+1, j+1); }
else if (j==n) solutie(i+1,1);
else solutie(i, j+1);
}
int main()
{
citire();
fout<<solutie(1,1)<<'\n';
for (i=1; i<=max; i++) fout<<sol[i]<<' ';
fin.close();
fout.close();
return 0;
}
Erorile sunt: Eroare de compilare: user.cpp:34:2: warning: no newline at end of file user.cpp: In function 'int solutie(int, int)': user.cpp:16: error: reference to 'max' is ambiguous user.cpp:7: error: candidates are: int max /usr/include/c++/4.2/bits/stl_algobase.h:246: error: template<class _Tp, class _Compare> const _Tp& std::max(const _Tp&, const _Tp&, _Compare) /usr/include/c++/4.2/bits/stl_algobase.h:204: error: template<class _Tp> const _Tp& std::max(const _Tp&, const _Tp&) user.cpp:16: error: reference to 'max' is ambiguous user.cpp:7: error: candidates are: int max /usr/include/c++/4.2/bits/stl_algobase.h:246: error: template<class _Tp, class _Compare> const _Tp& std::max(const _Tp&, const _Tp&, _Compare) /usr/include/c++/4.2/bits/stl_algobase.h:204: error: template<class _Tp> const _Tp& std::max(const _Tp&, const _Tp&) user.cpp:17: error: reference to 'max' is ambiguous user.cpp:7: error: candidates are: int max /usr/include/c++/4.2/bits/stl_algobase.h:246: error: template<class _Tp, class _Compare> const _Tp& std::max(const _Tp&, const _Tp&, _Compare) /usr/include/c++/4.2/bits/stl_algobase.h:204: error: template<class _Tp> const _Tp& std::max(const _Tp&, const _Tp&) user.cpp:17: error: reference to 'max' is ambiguous user.cpp:7: error: candidates are: int max /usr/include/c++/4.2/bits/stl_algobase.h:246: error: template<class _Tp, class _Compare> const _Tp& std::max(const _Tp&, const _Tp&, _Compare) /usr/include/c++/4.2/bits/stl_algobase.h:204: error: template<class _Tp> const _Tp& std::max(const _Tp&, const _Tp&) user.cpp: In function 'int main()': user.cpp:29: error: reference to 'max' is ambiguous user.cpp:7: error: candidates are: int max /usr/include/c++/4.2/bits/stl_algobase.h:246: error: template<class _Tp, class _Compare> const _Tp& std::max(const _Tp&, const _Tp&, _Compare) /usr/include/c++/4.2/bits/stl_algobase.h:204: error: template<class _Tp> const _Tp& std::max(const _Tp&, const _Tp&) user.cpp:29: error: reference to 'max' is ambiguous user.cpp:7: error: candidates are: int max /usr/include/c++/4.2/bits/stl_algobase.h:246: error: template<class _Tp, class _Compare> const _Tp& std::max(const _Tp&, const _Tp&, _Compare) /usr/include/c++/4.2/bits/stl_algobase.h:204: error: template<class _Tp> const _Tp& std::max(const _Tp&, const _Tp&)