Detalii evaluare #53041476

Rezumat problemă

#4704 MajorImpar C++

Subprogramul majImp are doi parametri, a și b, prin care primește câte un număr natural (2 ≤ a ≤ b ≤ 10.000). Subprogramul returnează cel mai mic număr major impar din intervalul [a,b], sau valoarea 0, dacă în interval nu există un astfel de număr. Scrieţi în C/C++ definiţia completă a subprogramului.

Detalii

Problema MajorImpar Operații I/O majimp.in/majimp.out
Limita timp 0.1 secunde Limita memorie Total: 2 MB / Stivă 1 MB
Id soluție #53041476 Utilizator Mandea Bogdan (Mandea_Bogdan)
Fișier majorimpar.cpp Dimensiune 403 B
Data încărcării 16 Octombrie 2024, 11:26 Scor / rezultat Eroare de compilare

Evaluare


Mesaj compilare

majorimpar.cpp:14:9: error: stray '\316' in program
         int Δp,Δi,d;

         ^
majorimpar.cpp:14:9: error: stray '\224' in program
majorimpar.cpp:14:9: error: stray '\316' in program
majorimpar.cpp:14:9: error: stray '\224' in program
majorimpar.cpp:18:13: error: stray '\316' in program
             Δp=Δp+d;

             ^
majorimpar.cpp:18:13: error: stray '\224' in program
majorimpar.cpp:18:13: error: stray '\316' in program
majorimpar.cpp:18:13: error: stray '\224' in program
majorimpar.cpp:20:13: error: stray '\316' in program
             Δi=Δi+d;

             ^
majorimpar.cpp:20:13: error: stray '\224' in program
majorimpar.cpp:20:13: error: stray '\316' in program
majorimpar.cpp:20:13: error: stray '\224' in program
majorimpar.cpp:21:13: error: stray '\316' in program
             if(Δi>Δp)

             ^
majorimpar.cpp:21:13: error: stray '\224' in program
majorimpar.cpp:21:13: error: stray '\316' in program
majorimpar.cpp:21:13: error: stray '\224' in program
majorimpar.cpp: In function 'int majImp(int, int)':
majorimpar.cpp:14:19: error: redeclaration of 'int i'
         int Δp,Δi,d;

                   ^
majorimpar.cpp:12:13: error: 'int i' previously declared here
     for(int i=a;i<=b;i++)

             ^
majorimpar.cpp:16:15: warning: suggest explicit braces to avoid ambiguous 'else' [-Wparentheses]
             if(i%d==0)

               ^
majorimpar.cpp:22:9: error: expected primary-expression before '}' token
         }

         ^
majorimpar.cpp:22:9: error: expected ';' before '}' token
majorimpar.cpp:23:16: error: 'i' was not declared in this scope
         return i;

                ^
majorimpar.cpp: In function 'int main()':
majorimpar.cpp:29:7: error: no match for 'operator<' (operand types are 'std::ostream {aka std::basic_ostream<char>}' and 'int')
   cout<majImp(a,b)

       ^
majorimpar.cpp:29:7: note: candidates are:
In file included from /usr/include/c++/4.8/bits/stl_algobase.h:64:0,
                 from /usr/include/c++/4.8/bits/char_traits.h:39,
                 from /usr/include/c++/4.8/ios:40,
                 from /usr/include/c++/4.8/istream:38,
                 from /usr/include/c++/4.8/fstream:38,
                 from majorimpar.cpp:1:
/usr/include/c++/4.8/bits/stl_pair.h:220:5: note: template<class _T1, class _T2> constexpr bool std::operator<(const std::pair<_T1, _T2>&, const std::pair<_T1, _T2>&)
     operator<(const pair<_T1, _T2>& __x, const pair<_T1, _T2>& __y)
     ^
/usr/include/c++/4.8/bits/stl_pair.h:220:5: note:   template argument deduction/substitution failed:
majorimpar.cpp:29:18: note:   'std::ostream {aka std::basic_ostream<char>}' is not derived from 'const std::pair<_T1, _T2>'
   cout<majImp(a,b)

                  ^
In file included from /usr/include/c++/4.8/bits/stl_algobase.h:67:0,
                 from /usr/include/c++/4.8/bits/char_traits.h:39,
                 from /usr/include/c++/4.8/ios:40,
                 from /usr/include/c++/4.8/istream:38,
                 from /usr/include/c++/4.8/fstream:38,
                 from majorimpar.cpp:1:
/usr/include/c++/4.8/bits/stl_iterator.h:297:5: note: template<class _Iterator> bool std::operator<(const std::reverse_iterator<_Iterator>&, const std::reverse_iterator<_Iterator>&)
     operator<(const reverse_iterator<_Iterator>& __x,
     ^
/usr/include/c++/4.8/bits/stl_iterator.h:297:5: note:   template argument deduction/substitution failed:
majorimpar.cpp:29:18: note:   'std::ostream {aka std::basic_ostream<char>}' is not derived from 'const std::reverse_iterator<_Iterator>'
   cout<majImp(a,b)

                  ^
In file included from /usr/include/c++/4.8/bits/stl_algobase.h:67:0,
                 from /usr/include/c++/4.8/bits/char_traits.h:39,
                 from /usr/include/c++/4.8/ios:40,
                 from /usr/include/c++/4.8/istream:38,
                 from /usr/include/c++/4.8/fstream:38,
                 from majorimpar.cpp:1:
/usr/include/c++/4.8/bits/stl_iterator.h:347:5: note: template<class _IteratorL, class _IteratorR> bool std::operator<(const std::reverse_iterator<_Iterator>&, const std::reverse_iterator<_IteratorR>&)
     operator<(const reverse_iterator<_IteratorL>& __x,
     ^
/usr/include/c++/4.8/bits/stl_iterator.h:347:5: note:   template argument deduction/substitution failed:
majorimpar.cpp:29:18: note:   'std::ostream {aka std::basic_ostream<char>}' is not derived from 'const std::reverse_iterator<_Iterator>'
   cout<majImp(a,b)

                  ^
In file included from /usr/include/c++/4.8/bits/stl_algobase.h:67:0,
                 from /usr/include/c++/4.8/bits/char_traits.h:39,
                 from /usr/include/c++/4.8/ios:40,
                 from /usr/include/c++/4.8/istream:38,
                 from /usr/include/c++/4.8/fstream:38,
                 from majorimpar.cpp:1:
/usr/include/c++/4.8/bits/stl_iterator.h:1055:5: note: template<class _IteratorL, class _IteratorR> bool std::operator<(const std::move_iterator<_Iterator>&, const std::move_iterator<_IteratorR>&)
     operator<(const move_iterator<_IteratorL>& __x,
     ^
/usr/include/c++/4.8/bits/stl_iterator.h:1055:5: note:   template argument deduction/substitution failed:
majorimpar.cpp:29:18: note:   'std::ostream {aka std::basic_ostream<char>}' is not derived from 'const std::move_iterator<_Iterator>'
   cout<majImp(a,b)

                  ^
In file included from /usr/include/c++/4.8/bits/stl_algobase.h:67:0,
                 from /usr/include/c++/4.8/bits/char_traits.h:39,
                 from /usr/include/c++/4.8/ios:40,
                 from /usr/include/c++/4.8/istream:38,
                 from /usr/include/c++/4.8/fstream:38,
                 from majorimpar.cpp:1:
/usr/include/c++/4.8/bits/stl_iterator.h:1061:5: note: template<class _Iterator> bool std::operator<(const std::move_iterator<_Iterator>&, const std::move_iterator<_Iterator>&)
     operator<(const move_iterator<_Iterator>& __x,
     ^
/usr/include/c++/4.8/bits/stl_iterator.h:1061:5: note:   template argument deduction/substitution failed:
majorimpar.cpp:29:18: note:   'std::ostream {aka std::basic_ostream<char>}' is not derived from 'const std::move_iterator<_Iterator>'
   cout<majImp(a,b)

                  ^
In file included from /usr/include/c++/4.8/string:52:0,
                 from /usr/include/c++/4.8/bits/locale_classes.h:40,
                 from /usr/include/c++/4.8/bits/ios_base.h:41,
                 from /usr/include/c++/4.8/ios:42,
                 from /usr/include/c++/4.8/istream:38,
                 from /usr/include/c++/4.8/fstream:38,
                 from majorimpar.cpp:1:
/usr/include/c++/4.8/bits/basic_string.h:2569:5: note: template<class _CharT, class _Traits, class _Alloc> bool std::operator<(const std::basic_string<_CharT, _Traits, _Alloc>&, const std::basic_string<_CharT, _Traits, _Alloc>&)
     operator<(const basic_string<_CharT, _Traits, _Alloc>& __lhs,
     ^
/usr/include/c++/4.8/bits/basic_string.h:2569:5: note:   template argument deduction/substitution failed:
majorimpar.cpp:29:18: note:   'std::ostream {aka std::basic_ostream<char>}' is not derived from 'const std::basic_string<_CharT, _Traits, _Alloc>'
   cout<majImp(a,b)

                  ^
In file included from /usr/include/c++/4.8/string:52:0,
                 from /usr/include/c++/4.8/bits/locale_classes.h:40,
                 from /usr/include/c++/4.8/bits/ios_base.h:41,
                 from /usr/include/c++/4.8/ios:42,
                 from /usr/include/c++/4.8/istream:38,
                 from /usr/include/c++/4.8/fstream:38,
                 from majorimpar.cpp:1:
/usr/include/c++/4.8/bits/basic_string.h:2581:5: note: template<class _CharT, class _Traits, class _Alloc> bool std::operator<(const std::basic_string<_CharT, _Traits, _Alloc>&, const _CharT*)
     operator<(const basic_string<_CharT, _Traits, _Alloc>& __lhs,
     ^
/usr/include/c++/4.8/bits/basic_string.h:2581:5: note:   template argument deduction/substitution failed:
majorimpar.cpp:29:18: note:   'std::ostream {aka std::basic_ostream<char>}' is not derived from 'const std::basic_string<_CharT, _Traits, _Alloc>'
   cout<majImp(a,b)

                  ^
In file included from /usr/include/c++/4.8/string:52:0,
                 from /usr/include/c++/4.8/bits/locale_classes.h:40,
                 from /usr/include/c++/4.8/bits/ios_base.h:41,
                 from /usr/include/c++/4.8/ios:42,
                 from /usr/include/c++/4.8/istream:38,
                 from /usr/include/c++/4.8/fstream:38,
                 from majorimpar.cpp:1:
/usr/include/c++/4.8/bits/basic_string.h:2593:5: note: template<class _CharT, class _Traits, class _Alloc> bool std::operator<(const _CharT*, const std::basic_string<_CharT, _Traits, _Alloc>&)
     operator<(const _CharT* __lhs,
     ^
/usr/include/c++/4.8/bits/basic_string.h:2593:5: note:   template argument deduction/substitution failed:
majorimpar.cpp:29:18: note:   mismatched types 'const _CharT*' and 'std::basic_ostream<char>'
   cout<majImp(a,b)

                  ^
majorimpar.cpp:30:5: error: expected ';' before 'return'
     return 0;

     ^
majorimpar.cpp: In function 'int main()':
majorimpar.cpp:33:5: error: redefinition of 'int main()'
 int main()

     ^
majorimpar.cpp:25:5: error: 'int main()' previously defined here
 int main()

     ^
majorimpar.cpp: In function 'int majImp(int, int)':
majorimpar.cpp:24:1: warning: control reaches end of non-void function [-Wreturn-type]
 }

 ^

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 MajorImpar 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ă.