#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 | #62509204 | Utilizator | |
| Fișier | iif.cpp | Dimensiune | 69 B |
| Data încărcării | 23 Ianuarie 2026, 13:57 | Scor/rezultat | Eroare de compilare |
iif.cpp:6:9: error: macro names must be identifiers #define (0, 0?) ^ iif.cpp:7:9: error: macro names must be identifiers #define (1, 1?) ^ iif.cpp:8:9: error: macro names must be identifiers #define , : ^ iif.cpp: In function 'int main()': iif.cpp:24:15: warning: left operand of comma operator has no effect [-Wunused-value] if(CHECK(0, "this is ONE", 10)==10) total++; ^ iif.cpp:24:30: warning: right operand of comma operator has no effect [-Wunused-value] if(CHECK(0, "this is ONE", 10)==10) total++; ^ iif.cpp:5:17: warning: suggest parentheses around comparison in operand of '==' [-Wparentheses] #define CHECK (1== ^ iif.cpp:24:6: note: in expansion of macro 'CHECK' if(CHECK(0, "this is ONE", 10)==10) total++; ^ iif.cpp:24:39: error: expected ')' before 'total' if(CHECK(0, "this is ONE", 10)==10) total++; ^ iif.cpp:25:22: warning: left operand of comma operator has no effect [-Wunused-value] if(strcmp(CHECK(1, "this will not be returned", "but this will"), "this will not be returned")==0) total++; ^ iif.cpp:25:51: warning: right operand of comma operator has no effect [-Wunused-value] if(strcmp(CHECK(1, "this will not be returned", "but this will"), "this will not be returned")==0) total++; ^ iif.cpp:25:66: error: ISO C++ forbids comparison between pointer and integer [-fpermissive] if(strcmp(CHECK(1, "this will not be returned", "but this will"), "this will not be returned")==0) total++; ^ iif.cpp:25:69: warning: right operand of comma operator has no effect [-Wunused-value] if(strcmp(CHECK(1, "this will not be returned", "but this will"), "this will not be returned")==0) total++; ^ iif.cpp:25:100: error: cannot convert 'bool' to 'const char*' for argument '1' to 'int strcmp(const char*, const char*)' if(strcmp(CHECK(1, "this will not be returned", "but this will"), "this will not be returned")==0) total++; ^ iif.cpp:25:102: error: expected ')' before 'total' 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ă.