#4263
Studiind instrucțiunea if, Alinutza a aflat că ramura else se asociază celui mai apropiat if neasociat încă. Aprofundând studiul, a extras din fiecare program scris cuvintele if și else. Din neatenție a transcris greșit, pierzând asocierea corectă if else. Ajutați-o voi să aibă scrierea corectă, folosind un număr minim de modificări. O modificare înseamnă să înlocuim un cuvânt if cu else sau un cuvânt else cu if.
| Problema | ifelse | Operații I/O |
ifelse.in/ifelse.out
|
|---|---|---|---|
| Limita timp | 0.1 secunde | Limita memorie |
Total: 64 MB
/
Stivă 8 MB
|
| Id soluție | #62425578 | Utilizator | |
| Fișier | ifelse.cpp | Dimensiune | 765 B |
| Data încărcării | 21 Ianuarie 2026, 09:57 | Scor/rezultat | Eroare de compilare |
ifelse.cpp:3:14: error: 'ifelse' was not declared in this scope ifstream fin(ifelse.in); ^ ifelse.cpp:4:15: error: 'ifelse' was not declared in this scope ofstream fout(ifelse.out); ^ ifelse.cpp: In function 'void push(stiva&, char)': ifelse.cpp:9:33: error: 'struct stiva' has no member named 'v' void push(stiva &S, char x) { S.v[++S.vf]=x;} ^ ifelse.cpp: In function 'int schimbari(char*)': ifelse.cpp:16:20: error: cannot convert 'stiva' to 'char*' for argument '1' to 'char* strtok(char*, const char*)' p=strtok(S, " "); ^ ifelse.cpp:21:25: error: invalid initialization of reference of type 'stiva&' from expression of type 'char*' else push(s, 'i'); ^ ifelse.cpp:9:6: error: in passing argument 1 of 'void push(stiva&, char)' void push(stiva &S, char x) { S.v[++S.vf]=x;} ^ ifelse.cpp:23:14: error: 'soze' was not declared in this scope if(soze(s)%2!=0) return-1; ^ ifelse.cpp:24:21: error: could not convert 's' from 'char*' to 'stiva' return nr+size(s)/2; } ^ ifelse.cpp: In function 'int main()': ifelse.cpp:26:10: error: 'n' was not declared in this scope fin>>n; fin.get(); ^ ifelse.cpp:28:21: error: 's' was not declared in this scope fin.getline(s, 50000); ^ ifelse.cpp: In function 'int schimbari(char*)': ifelse.cpp:24:26: warning: control reaches end of non-void function [-Wreturn-type] return nr+size(s)/2; } ^
www.pbinfo.ro permite evaluarea a două tipuri de probleme:
Problema ifelse face parte din prima categorie. 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ă.