Detalii evaluare #54938928

Rezumat problemă

#4725 f_prod_max C++

Subprogramul produsmaxim primește prin parametrul n un număr natural și determină o modalitate de a tăia numărul n în două alte numere care să aibă produsul maxim. De exemplu, numărul 2244 poare fi tăiat în următoarele feluri: 2 și 244, 22 și 44, respectiv 224 și 4. Produsul maxim obținut este 968 prin înmulțirea numerelor 22 și 44. Subprogramul furnizează prin parametrul pmax valoarea maximă a produsului și prin parametrii st și dr cele două numere în care a fost împărțit numărul n pentru avea produsul maxim. Parametrul st va reține partea stângă a numărului, iar parametrul dr partea dreaptă conform tăierii numărului dat. Scrieți definiția completă a subprogramului.

Detalii

Problema f_prod_max Operații I/O tastatură/ecran
Limita timp 0.1 secunde Limita memorie Total: 64 MB / Stivă 8 MB
Id soluție #54938928 Utilizator Ciurbe Bogdan (Bogdi_ok)
Fișier f_prod_max.cpp Dimensiune 506 B
Data încărcării 12 Decembrie 2024, 20:05 Scor / rezultat Eroare de compilare

Evaluare


Mesaj compilare

f_prod_max.cpp: In function 'void produsmaxim(int, int&, int&, int&)':
f_prod_max.cpp:18:49: warning: pointer to a function used in arithmetic [-Wpointer-arith]
     int nrc=nrcifre(n),aux=n,edr=pow(10,nrcifre-1),est=10,st1,dr1;

                                                 ^
f_prod_max.cpp:18:50: error: no matching function for call to 'pow(int, int (*)(int))'
     int nrc=nrcifre(n),aux=n,edr=pow(10,nrcifre-1),est=10,st1,dr1;

                                                  ^
f_prod_max.cpp:18:50: note: candidates are:
In file included from /usr/include/features.h:374:0,
                 from /usr/include/i386-linux-gnu/c++/4.8/bits/os_defines.h:39,
                 from /usr/include/i386-linux-gnu/c++/4.8/bits/c++config.h:426,
                 from /usr/include/c++/4.8/iostream:38,
                 from f_prod_max.cpp:1:
/usr/include/i386-linux-gnu/bits/mathcalls.h:153:1: note: double pow(double, double)
 __MATHCALL (pow,, (_Mdouble_ __x, _Mdouble_ __y));
 ^
/usr/include/i386-linux-gnu/bits/mathcalls.h:153:1: note:   no known conversion for argument 2 from 'int (*)(int)' to 'double'
In file included from /usr/include/c++/4.8/valarray:587:0,
                 from /usr/include/i386-linux-gnu/c++/4.8/bits/stdc++.h:94,
                 from f_prod_max.cpp:4:
/usr/include/c++/4.8/bits/valarray_after.h:544:1: note: template<class _Tp> std::_Expr<std::_BinClos<std::_Pow, std::_Constant, std::_ValArray, _Tp, _Tp>, _Tp> std::pow(const _Tp&, const std::valarray<_Tp>&)
 _DEFINE_EXPR_BINARY_FUNCTION(pow, _Pow)
 ^
/usr/include/c++/4.8/bits/valarray_after.h:544:1: note:   template argument deduction/substitution failed:
f_prod_max.cpp:18:50: note:   mismatched types 'const std::valarray<_Tp>' and 'int (*)(int)'
     int nrc=nrcifre(n),aux=n,edr=pow(10,nrcifre-1),est=10,st1,dr1;

                                                  ^
In file included from /usr/include/c++/4.8/valarray:587:0,
                 from /usr/include/i386-linux-gnu/c++/4.8/bits/stdc++.h:94,
                 from f_prod_max.cpp:4:
/usr/include/c++/4.8/bits/valarray_after.h:544:1: note: template<class _Tp> std::_Expr<std::_BinClos<std::_Pow, std::_ValArray, std::_Constant, _Tp, _Tp>, _Tp> std::pow(const std::valarray<_Tp>&, const _Tp&)
 _DEFINE_EXPR_BINARY_FUNCTION(pow, _Pow)
 ^
/usr/include/c++/4.8/bits/valarray_after.h:544:1: note:   template argument deduction/substitution failed:
f_prod_max.cpp:18:50: note:   mismatched types 'const std::valarray<_Tp>' and 'int'
     int nrc=nrcifre(n),aux=n,edr=pow(10,nrcifre-1),est=10,st1,dr1;

                                                  ^
In file included from /usr/include/c++/4.8/valarray:587:0,
                 from /usr/include/i386-linux-gnu/c++/4.8/bits/stdc++.h:94,
                 from f_prod_max.cpp:4:
/usr/include/c++/4.8/bits/valarray_after.h:544:1: note: template<class _Tp> std::_Expr<std::_BinClos<std::_Pow, std::_ValArray, std::_ValArray, _Tp, _Tp>, _Tp> std::pow(const std::valarray<_Tp>&, const std::valarray<_Tp>&)
 _DEFINE_EXPR_BINARY_FUNCTION(pow, _Pow)
 ^
/usr/include/c++/4.8/bits/valarray_after.h:544:1: note:   template argument deduction/substitution failed:
f_prod_max.cpp:18:50: note:   mismatched types 'const std::valarray<_Tp>' and 'int'
     int nrc=nrcifre(n),aux=n,edr=pow(10,nrcifre-1),est=10,st1,dr1;

                                                  ^
In file included from /usr/include/c++/4.8/valarray:587:0,
                 from /usr/include/i386-linux-gnu/c++/4.8/bits/stdc++.h:94,
                 from f_prod_max.cpp:4:
/usr/include/c++/4.8/bits/valarray_after.h:544:1: note: template<class _Dom> std::_Expr<std::_BinClos<std::_Pow, std::_Constant, std::_Expr, typename _Dom::value_type, _Dom>, typename _Dom::value_type> std::pow(const typename _Dom::value_type&, const std::_Expr<_Dom1, typename _Dom1::value_type>&)
 _DEFINE_EXPR_BINARY_FUNCTION(pow, _Pow)
 ^
/usr/include/c++/4.8/bits/valarray_after.h:544:1: note:   template argument deduction/substitution failed:
f_prod_max.cpp:18:50: note:   mismatched types 'const std::_Expr<_Dom1, typename _Dom1::value_type>' and 'int (*)(int)'
     int nrc=nrcifre(n),aux=n,edr=pow(10,nrcifre-1),est=10,st1,dr1;

                                                  ^
In file included from /usr/include/c++/4.8/valarray:587:0,
                 from /usr/include/i386-linux-gnu/c++/4.8/bits/stdc++.h:94,
                 from f_prod_max.cpp:4:
/usr/include/c++/4.8/bits/valarray_after.h:544:1: note: template<class _Dom> std::_Expr<std::_BinClos<std::_Pow, std::_Expr, std::_Constant, _Dom, typename _Dom::value_type>, typename _Dom::value_type> std::pow(const std::_Expr<_Dom1, typename _Dom1::value_type>&, const typename _Dom::value_type&)
 _DEFINE_EXPR_BINARY_FUNCTION(pow, _Pow)
 ^
/usr/include/c++/4.8/bits/valarray_after.h:544:1: note:   template argument deduction/substitution failed:
f_prod_max.cpp:18:50: note:   mismatched types 'const std::_Expr<_Dom1, typename _Dom1::value_type>' and 'int'
     int nrc=nrcifre(n),aux=n,edr=pow(10,nrcifre-1),est=10,st1,dr1;

                                                  ^
In file included from /usr/include/c++/4.8/valarray:587:0,
                 from /usr/include/i386-linux-gnu/c++/4.8/bits/stdc++.h:94,
                 from f_prod_max.cpp:4:
/usr/include/c++/4.8/bits/valarray_after.h:544:1: note: template<class _Dom> std::_Expr<std::_BinClos<std::_Pow, std::_ValArray, std::_Expr, typename _Dom::value_type, _Dom>, typename _Dom::value_type> std::pow(const std::valarray<typename _Dom::valarray>&, const std::_Expr<_Dom1, typename _Dom1::value_type>&)
 _DEFINE_EXPR_BINARY_FUNCTION(pow, _Pow)
 ^
/usr/include/c++/4.8/bits/valarray_after.h:544:1: note:   template argument deduction/substitution failed:
f_prod_max.cpp:18:50: note:   mismatched types 'const std::valarray<typename _Dom::valarray>' and 'int'
     int nrc=nrcifre(n),aux=n,edr=pow(10,nrcifre-1),est=10,st1,dr1;

                                                  ^
In file included from /usr/include/c++/4.8/valarray:587:0,
                 from /usr/include/i386-linux-gnu/c++/4.8/bits/stdc++.h:94,
                 from f_prod_max.cpp:4:
/usr/include/c++/4.8/bits/valarray_after.h:544:1: note: template<class _Dom> std::_Expr<std::_BinClos<std::_Pow, std::_Expr, std::_ValArray, _Dom, typename _Dom::value_type>, typename _Dom::value_type> std::pow(const std::_Expr<_Dom1, typename _Dom1::value_type>&, const std::valarray<typename _Dom::value_type>&)
 _DEFINE_EXPR_BINARY_FUNCTION(pow, _Pow)
 ^
/usr/include/c++/4.8/bits/valarray_after.h:544:1: note:   template argument deduction/substitution failed:
f_prod_max.cpp:18:50: note:   mismatched types 'const std::_Expr<_Dom1, typename _Dom1::value_type>' and 'int'
     int nrc=nrcifre(n),aux=n,edr=pow(10,nrcifre-1),est=10,st1,dr1;

                                                  ^
In file included from /usr/include/c++/4.8/valarray:587:0,
                 from /usr/include/i386-linux-gnu/c++/4.8/bits/stdc++.h:94,
                 from f_prod_max.cpp:4:
/usr/include/c++/4.8/bits/valarray_after.h:544:1: note: template<class _Dom1, class _Dom2> std::_Expr<std::_BinClos<std::_Pow, std::_Expr, std::_Expr, _Dom1, _Dom2>, typename _Dom1::value_type> std::pow(const std::_Expr<_Dom1, typename _Dom1::value_type>&, const std::_Expr<_Dom2, typename _Dom2::value_type>&)
 _DEFINE_EXPR_BINARY_FUNCTION(pow, _Pow)
 ^
/usr/include/c++/4.8/bits/valarray_after.h:544:1: note:   template argument deduction/substitution failed:
f_prod_max.cpp:18:50: note:   mismatched types 'const std::_Expr<_Dom1, typename _Dom1::value_type>' and 'int'
     int nrc=nrcifre(n),aux=n,edr=pow(10,nrcifre-1),est=10,st1,dr1;

                                                  ^
In file included from /usr/include/c++/4.8/ccomplex:38:0,
                 from /usr/include/i386-linux-gnu/c++/4.8/bits/stdc++.h:52,
                 from f_prod_max.cpp:4:
/usr/include/c++/4.8/complex:1871:5: note: template<class _Tp, class _Up> std::complex<typename __gnu_cxx::__promote_2<_Tp, _Up>::__type> std::pow(const std::complex<_Tp>&, const std::complex<_Up>&)
     pow(const std::complex<_Tp>& __x, const std::complex<_Up>& __y)
     ^
/usr/include/c++/4.8/complex:1871:5: note:   template argument deduction/substitution failed:
f_prod_max.cpp:18:50: note:   mismatched types 'const std::complex<_Tp>' and 'int'
     int nrc=nrcifre(n),aux=n,edr=pow(10,nrcifre-1),est=10,st1,dr1;

                                                  ^
In file included from /usr/include/c++/4.8/ccomplex:38:0,
                 from /usr/include/i386-linux-gnu/c++/4.8/bits/stdc++.h:52,
                 from f_prod_max.cpp:4:
/usr/include/c++/4.8/complex:1863:5: note: template<class _Tp, class _Up> std::complex<typename __gnu_cxx::__promote_2<_Tp, _Up>::__type> std::pow(const _Tp&, const std::complex<_Up>&)
     pow(const _Tp& __x, const std::complex<_Up>& __y)
     ^
/usr/include/c++/4.8/complex:1863:5: note:   template argument deduction/substitution failed:
f_prod_max.cpp:18:50: note:   mismatched types 'const std::complex<_Up>' and 'int (*)(int)'
     int nrc=nrcifre(n),aux=n,edr=pow(10,nrcifre-1),est=10,st1,dr1;

                                                  ^
In file included from /usr/include/c++/4.8/ccomplex:38:0,
                 from /usr/include/i386-linux-gnu/c++/4.8/bits/stdc++.h:52,
                 from f_prod_max.cpp:4:
/usr/include/c++/4.8/complex:1855:5: note: template<class _Tp, class _Up> std::complex<typename __gnu_cxx::__promote_2<_Tp, _Up>::__type> std::pow(const std::complex<_Tp>&, const _Up&)
     pow(const std::complex<_Tp>& __x, const _Up& __y)
     ^
/usr/include/c++/4.8/complex:1855:5: note:   template argument deduction/substitution failed:
f_prod_max.cpp:18:50: note:   mismatched types 'const std::complex<_Tp>' and 'int'
     int nrc=nrcifre(n),aux=n,edr=pow(10,nrcifre-1),est=10,st1,dr1;

                                                  ^
In file included from /usr/include/c++/4.8/ccomplex:38:0,
                 from /usr/include/i386-linux-gnu/c++/4.8/bits/stdc++.h:52,
                 from f_prod_max.cpp:4:
/usr/include/c++/4.8/complex:1034:5: note: template<class _Tp> std::complex<_Tp> std::pow(const _Tp&, const std::complex<_Tp>&)
     pow(const _Tp& __x, const complex<_Tp>& __y)
     ^
/usr/include/c++/4.8/complex:1034:5: note:   template argument deduction/substitution failed:
f_prod_max.cpp:18:50: note:   mismatched types 'const std::complex<_Tp>' and 'int (*)(int)'
     int nrc=nrcifre(n),aux=n,edr=pow(10,nrcifre-1),est=10,st1,dr1;

                                                  ^
In file included from /usr/include/c++/4.8/ccomplex:38:0,
                 from /usr/include/i386-linux-gnu/c++/4.8/bits/stdc++.h:52,
                 from f_prod_max.cpp:4:
/usr/include/c++/4.8/complex:1023:5: note: template<class _Tp> std::complex<_Tp> std::pow(const std::complex<_Tp>&, const std::complex<_Tp>&)
     pow(const complex<_Tp>& __x, const complex<_Tp>& __y)
     ^
/usr/include/c++/4.8/complex:1023:5: note:   template argument deduction/substitution failed:
f_prod_max.cpp:18:50: note:   mismatched types 'const std::complex<_Tp>' and 'int'
     int nrc=nrcifre(n),aux=n,edr=pow(10,nrcifre-1),est=10,st1,dr1;

                                                  ^
In file included from /usr/include/c++/4.8/ccomplex:38:0,
                 from /usr/include/i386-linux-gnu/c++/4.8/bits/stdc++.h:52,
                 from f_prod_max.cpp:4:
/usr/include/c++/4.8/complex:989:5: note: template<class _Tp> std::complex<_Tp> std::pow(const std::complex<_Tp>&, const _Tp&)
     pow(const complex<_Tp>& __x, const _Tp& __y)
     ^
/usr/include/c++/4.8/complex:989:5: note:   template argument deduction/substitution failed:
f_prod_max.cpp:18:50: note:   mismatched types 'const std::complex<_Tp>' and 'int'
     int nrc=nrcifre(n),aux=n,edr=pow(10,nrcifre-1),est=10,st1,dr1;

                                                  ^
In file included from /usr/include/i386-linux-gnu/c++/4.8/bits/stdc++.h:41:0,
                 from f_prod_max.cpp:4:
/usr/include/c++/4.8/cmath:434:5: note: template<class _Tp, class _Up> constexpr typename __gnu_cxx::__promote_2<_Tp, _Up>::__type std::pow(_Tp, _Up)
     pow(_Tp __x, _Up __y)
     ^
/usr/include/c++/4.8/cmath:434:5: note:   template argument deduction/substitution failed:
/usr/include/c++/4.8/cmath: In substitution of 'template<class _Tp, class _Up> constexpr typename __gnu_cxx::__promote_2<_Tp, _Up>::__type std::pow(_Tp, _Up) [with _Tp = int; _Up = int (*)(int)]':
f_prod_max.cpp:18:50:   required from here
/usr/include/c++/4.8/cmath:434:5: error: no type named '__type' in 'struct __gnu_cxx::__promote<int (*)(int), false>'
/usr/include/c++/4.8/cmath:411:3: note: constexpr long double std::pow(long double, long double)
   pow(long double __x, long double __y)
   ^
/usr/include/c++/4.8/cmath:411:3: note:   no known conversion for argument 2 from 'int (*)(int)' to 'long double'
/usr/include/c++/4.8/cmath:407:3: note: constexpr float std::pow(float, float)
   pow(float __x, float __y)
   ^
/usr/include/c++/4.8/cmath:407:3: note:   no known conversion for argument 2 from 'int (*)(int)' to 'float'
f_prod_max.cpp:21:9: error: 'dr1' was not declared in this scope
         dr1=n%edr;

         ^
f_prod_max.cpp:22:9: error: 'st1' was not declared in this scope
         st1=(n/edr)%est;

         ^
f_prod_max.cpp:22:21: error: 'est' was not declared in this scope
         st1=(n/edr)%est;

                     ^
f_prod_max.cpp:18:9: warning: unused variable 'nrc' [-Wunused-variable]
     int nrc=nrcifre(n),aux=n,edr=pow(10,nrcifre-1),est=10,st1,dr1;

         ^

Cum funcționează evaluarea?

www.pbinfo.ro permite evaluarea a două tipuri de probleme:

  • probleme la care rezolvarea presupune scrierea unui program complet
  • probleme la care rezolvarea presupune scrierea unei secvențe de program - câteva instrucțiuni, o listă de declarații, una sau mai multe funcții, etc.

Problema f_prod_max face parte din a doua categorie. Pentru aceste probleme se folosește un program suport, furnizat de propunătorul problemei. Soluția propusă de tine va fi evaluată astfel:

  • Soluția propusă de tine este inclusă în programul suport, apoi acesta este compilat. Dacă în urma compilării se obțin erori sau avertismente, acestea sunt afișate în această pagină.
  • Datorită existenței programului suport, la compilare pot să apară erori sau avertismente care să nu se refere la instrucțiunile scrise de tine, dar care sunt datorate faptului că soluția ta nu este corectă.
  • Dacă programul suport a fost compilat, executabilul obținut va fi rulat, furnizându-i-se unul sau mai multe seturi de date de intrare, în concordanță cu restricțiile specifice problemei. Pentru fiecare set de date se obține un anumit punctaj, în raport cu corectitudinea soluției tale.

Suma punctajelor acordate pe testele utilizate pentru verificare este 100. Astfel, soluția ta poate obține cel mult 100 de puncte, caz în care se poate considera corectă.