Detalii evaluare #64909373

Rezumat problemă

IIF
C++
#3412

Redefiniți instruțiunea condițională if, printr-o secvență de directive #define.

Detalii

Problema IIF Operații I/O tastatură/ecran
Limita timp 0.1 secunde Limita memorie Total: 64 MB / Stivă 8 MB
Id soluție #64909373 Utilizator Mihai Eduard Colibaba (Edy1404)
Fișier iif.cpp Dimensiune 44 B
Data încărcării 11 Iunie 2026, 18:10 Scor/rezultat Eroare de compilare

Evaluare

Mesaj compilare

iif.cpp: In function ‘int main()’:
iif.cpp:5:22: warning: init-statement in selection statements only available with ‘-std=c++17’ or ‘-std=gnu++17’ [-Wc++17-extensions]
    5 | #define CHECK(x,t,y) (x==0)?cout<<y:cout<<t;
      |                      ^
iif.cpp:14:6: note: in expansion of macro ‘CHECK’
   14 |   if(CHECK(0, "this is ONE", 10)==10) total++;
      |      ^~~~~
iif.cpp:5:29: error: ‘cout’ was not declared in this scope; did you mean ‘std::cout’?
    5 | #define CHECK(x,t,y) (x==0)?cout<<y:cout<<t;
      |                             ^~~~
iif.cpp:14:6: note: in expansion of macro ‘CHECK’
   14 |   if(CHECK(0, "this is ONE", 10)==10) total++;
      |      ^~~~~
In file included from iif.cpp:1:
/usr/include/c++/13/iostream:63:18: note: ‘std::cout’ declared here
   63 |   extern ostream cout;          ///< Linked to standard output
      |                  ^~~~
iif.cpp:14:33: error: expected primary-expression before ‘==’ token
   14 |   if(CHECK(0, "this is ONE", 10)==10) total++;
      |                                 ^~
iif.cpp:5:29: error: ‘cout’ was not declared in this scope; did you mean ‘std::cout’?
    5 | #define CHECK(x,t,y) (x==0)?cout<<y:cout<<t;
      |                             ^~~~
iif.cpp:15:13: note: in expansion of macro ‘CHECK’
   15 |   if(strcmp(CHECK(1, "this will not be returned", "but this will"), "this will not be returned")==0) total++;
      |             ^~~~~
/usr/include/c++/13/iostream:63:18: note: ‘std::cout’ declared here
   63 |   extern ostream cout;          ///< Linked to standard output
      |                  ^~~~
iif.cpp:5:44: error: expected ‘)’ before ‘;’ token
    5 | #define CHECK(x,t,y) (x==0)?cout<<y:cout<<t;
      |                                            ^
iif.cpp:15:13: note: in expansion of macro ‘CHECK’
   15 |   if(strcmp(CHECK(1, "this will not be returned", "but this will"), "this will not be returned")==0) total++;
      |             ^~~~~
iif.cpp:15:5: note: to match this ‘(’
   15 |   if(strcmp(CHECK(1, "this will not be returned", "but this will"), "this will not be returned")==0) total++;
      |     ^
iif.cpp:15:3: warning: this ‘if’ clause does not guard... [-Wmisleading-indentation]
   15 |   if(strcmp(CHECK(1, "this will not be returned", "but this will"), "this will not be returned")==0) total++;
      |   ^~
iif.cpp:15:67: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the ‘if’
   15 |   if(strcmp(CHECK(1, "this will not be returned", "but this will"), "this will not be returned")==0) total++;
      |                                                                   ^
iif.cpp:15:67: error: expected primary-expression before ‘,’ token

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

Du-te sus!