#3412
Redefiniți instruțiunea condițională if, printr-o secvență de directive #define.
| Problema | IIF | Operații I/O |
tastatură/ecran
|
|---|---|---|---|
| Limita timp | 0.1 secunde | Limita memorie |
Total: 64 MB
/
Stivă 8 MB
|
| Id soluție | #64909376 | Utilizator | |
| Fișier | iif.cpp | Dimensiune | 154 B |
| Data încărcării | 11 Iunie 2026, 18:11 | Scor/rezultat | Eroare de compilare |
iif.cpp:20:5: error: redefinition of ‘int main()’ 20 | int main() | ^~~~ iif.cpp:12:5: note: ‘int main()’ previously defined here 12 | int main() { | ^~~~ iif.cpp: In function ‘int main()’: iif.cpp:9:22: warning: init-statement in selection statements only available with ‘-std=c++17’ or ‘-std=gnu++17’ [-Wc++17-extensions] 9 | #define CHECK(x,t,y) (x==0)?cout<<y:cout<<t; | ^ iif.cpp:40:6: note: in expansion of macro ‘CHECK’ 40 | if(CHECK(0, "this is ONE", 10)==10) total++; | ^~~~~ iif.cpp:40:33: error: expected primary-expression before ‘==’ token 40 | if(CHECK(0, "this is ONE", 10)==10) total++; | ^~ iif.cpp:9:44: error: expected ‘)’ before ‘;’ token 9 | #define CHECK(x,t,y) (x==0)?cout<<y:cout<<t; | ^ iif.cpp:41:13: note: in expansion of macro ‘CHECK’ 41 | if(strcmp(CHECK(1, "this will not be returned", "but this will"), "this will not be returned")==0) total++; | ^~~~~ iif.cpp:41:12: note: to match this ‘(’ 41 | if(strcmp(CHECK(1, "this will not be returned", "but this will"), "this will not be returned")==0) total++; | ^ iif.cpp:9:44: error: expected ‘)’ before ‘;’ token 9 | #define CHECK(x,t,y) (x==0)?cout<<y:cout<<t; | ^ iif.cpp:41:13: note: in expansion of macro ‘CHECK’ 41 | if(strcmp(CHECK(1, "this will not be returned", "but this will"), "this will not be returned")==0) total++; | ^~~~~ iif.cpp:41:5: note: to match this ‘(’ 41 | if(strcmp(CHECK(1, "this will not be returned", "but this will"), "this will not be returned")==0) total++; | ^ iif.cpp:41:3: warning: this ‘if’ clause does not guard... [-Wmisleading-indentation] 41 | if(strcmp(CHECK(1, "this will not be returned", "but this will"), "this will not be returned")==0) total++; | ^~ iif.cpp:41:67: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the ‘if’ 41 | if(strcmp(CHECK(1, "this will not be returned", "but this will"), "this will not be returned")==0) total++; | ^ iif.cpp:41:67: error: expected primary-expression before ‘,’ token
www.pbinfo.ro permite evaluarea a două tipuri de probleme:
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:
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ă.