#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 | #64008730 | Utilizator | |
| Fișier | iif.cpp | Dimensiune | 51 B |
| Data încărcării | 04 Aprilie 2026, 16:59 | Scor/rezultat | Eroare de compilare |
iif.cpp:14:32: error: pasting ""\"this is ONE\""" and ""10"" does not give a valid preprocessing token if(CHECK(0, "this is ONE", 10)==10) total++; ^ iif.cpp:5:25: note: in definition of macro 'CHECK' #define CHECK(x, y, z) #y ## #z ## (x == 0 ? z : y) ^ iif.cpp:14:32: error: pasting ""10"" and "(" does not give a valid preprocessing token if(CHECK(0, "this is ONE", 10)==10) total++; ^ iif.cpp:5:31: note: in definition of macro 'CHECK' #define CHECK(x, y, z) #y ## #z ## (x == 0 ? z : y) ^ iif.cpp:15:66: error: pasting ""\"this will not be returned\""" and ""\"but this will\""" does not give a valid preprocessing token if(strcmp(CHECK(1, "this will not be returned", "but this will"), "this will not be returned")==0) total++; ^ iif.cpp:5:25: note: in definition of macro 'CHECK' #define CHECK(x, y, z) #y ## #z ## (x == 0 ? z : y) ^ iif.cpp:15:66: error: pasting ""\"but this will\""" and "(" does not give a valid preprocessing token if(strcmp(CHECK(1, "this will not be returned", "but this will"), "this will not be returned")==0) total++; ^ iif.cpp:5:31: note: in definition of macro 'CHECK' #define CHECK(x, y, z) #y ## #z ## (x == 0 ? z : y) ^ iif.cpp: In function 'int main()': iif.cpp:14:15: error: operands to ?: have different types 'int' and 'const char*' if(CHECK(0, "this is ONE", 10)==10) total++; ^ iif.cpp:5:50: note: in definition of macro 'CHECK' #define CHECK(x, y, z) #y ## #z ## (x == 0 ? z : y) ^ iif.cpp:5:51: error: expression cannot be used as a function #define CHECK(x, y, z) #y ## #z ## (x == 0 ? z : y) ^ iif.cpp:14:6: note: in expansion of macro 'CHECK' if(CHECK(0, "this is ONE", 10)==10) total++; ^ iif.cpp:5:51: error: expression cannot be used as a function #define CHECK(x, y, z) #y ## #z ## (x == 0 ? z : y) ^ iif.cpp:15:13: note: in expansion of macro 'CHECK' if(strcmp(CHECK(1, "this will not be returned", "but this will"), "this will not be returned")==0) total++; ^
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ă.