#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 | #62425489 | Utilizator | |
| Fișier | ifelse.cpp | Dimensiune | 658 B |
| Data încărcării | 21 Ianuarie 2026, 09:54 | Scor/rezultat | Eroare de compilare |
ifelse.cpp:3:11: error: variable or field 'push' declared void void push(stiva &s, char x) { S.v[++S.vf]=x;} ^ ifelse.cpp:3:11: error: 'stiva' was not declared in this scope ifelse.cpp:3:18: error: 's' was not declared in this scope void push(stiva &s, char x) { S.v[++S.vf]=x;} ^ ifelse.cpp:3:21: error: expected primary-expression before 'char' void push(stiva &s, char x) { S.v[++S.vf]=x;} ^ ifelse.cpp:4:10: error: variable or field 'pop' declared void void pop(stiva &S) {S.vf--;} ^ ifelse.cpp:4:10: error: 'stiva' was not declared in this scope ifelse.cpp:4:17: error: 'S' was not declared in this scope void pop(stiva &S) {S.vf--;} ^ ifelse.cpp:5:14: error: 'stiva' was not declared in this scope bool isempty(stiva S) {return S.vf<0;} ^ ifelse.cpp:5:23: error: expected ',' or ';' before '{' token bool isempty(stiva S) {return S.vf<0;} ^ ifelse.cpp:6:10: error: 'stiva' was not declared in this scope int size(stiva S) {return S.vf+1;} ^ ifelse.cpp:6:19: error: expected ',' or ';' before '{' token int size(stiva S) {return S.vf+1;} ^ ifelse.cpp: In function 'int schimbari(char*)': ifelse.cpp:9:5: error: 'S' was not declared in this scope S.vf=-1; ^ ifelse.cpp:13:25: error: 'isempty' cannot be used as a function if(isempty(S)) nr++, push(S, 'i'); ^ ifelse.cpp:13:45: error: 'push' was not declared in this scope if(isempty(S)) nr++, push(S, 'i'); ^ ifelse.cpp:14:20: error: 'pop' was not declared in this scope else pop(S); ^ ifelse.cpp:15:25: error: 'push' was not declared in this scope else push(s, 'i'); ^ ifelse.cpp:17:14: error: 'soze' was not declared in this scope if(soze(s)%2!=0) return-1; ^ ifelse.cpp:18:21: error: 'size' cannot be used as a function return nr+size(s)/2; } ^ ifelse.cpp: In function 'int main()': ifelse.cpp:20:5: error: 'fin' was not declared in this scope fin>>n; fin.get(); ^ ifelse.cpp:20:10: error: 'n' was not declared in this scope fin>>n; fin.get(); ^ ifelse.cpp:22:21: error: 's' was not declared in this scope fin.getline(s, 50000); ^ ifelse.cpp:23:9: error: 'fout' was not declared in this scope fout<<schimbari(s)<<'\n'; ^ ifelse.cpp: In function 'int schimbari(char*)': ifelse.cpp:18: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ă.