#1365
Se dau n numere întregi. Să se insereze între oricare două numere de aceeași paritate media lor aritmetică.
| Problema | aceeasi_paritate | Operații I/O |
tastatură/ecran
|
|---|---|---|---|
| Limita timp | 0.1 secunde | Limita memorie |
Total: 64 MB
/
Stivă 8 MB
|
| Id soluție | #63738867 | Utilizator | |
| Fișier | aceeasi_paritate.cpp | Dimensiune | 3.54 KB |
| Data încărcării | 17 Martie 2026, 11:46 | Scor/rezultat | Eroare de compilare |
aceeasi_paritate.cpp:33:1: error: stray '\360' in program 🔴 Issues ^ aceeasi_paritate.cpp:33:1: error: stray '\237' in program aceeasi_paritate.cpp:33:1: error: stray '\224' in program aceeasi_paritate.cpp:33:1: error: stray '\264' in program aceeasi_paritate.cpp:37:1: error: stray '\342' in program When i == n-1, v[i+2] becomes v[n+1] → invalid memory access. ^ aceeasi_paritate.cpp:37:1: error: stray '\206' in program aceeasi_paritate.cpp:37:1: error: stray '\222' in program aceeasi_paritate.cpp:45:1: error: stray '\342' in program ✔️ You should store the original value before shifting. ^ aceeasi_paritate.cpp:45:1: error: stray '\234' in program aceeasi_paritate.cpp:45:1: error: stray '\224' in program aceeasi_paritate.cpp:45:1: error: stray '\357' in program aceeasi_paritate.cpp:45:1: error: stray '\270' in program aceeasi_paritate.cpp:45:1: error: stray '\217' in program aceeasi_paritate.cpp:51:1: error: stray '\342' in program But you increase n → possible overflow. ^ aceeasi_paritate.cpp:51:1: error: stray '\206' in program aceeasi_paritate.cpp:51:1: error: stray '\222' in program aceeasi_paritate.cpp:56:1: error: stray '\342' in program ✅ Fixed Version ^ aceeasi_paritate.cpp:56:1: error: stray '\234' in program aceeasi_paritate.cpp:56:1: error: stray '\205' in program aceeasi_paritate.cpp:57:1: error: stray '\342' in program Here’s a corrected and safer version: ^ aceeasi_paritate.cpp:57:1: error: stray '\200' in program aceeasi_paritate.cpp:57:1: error: stray '\231' in program aceeasi_paritate.cpp:93:1: error: stray '\360' in program 🧠 What it does now ^ aceeasi_paritate.cpp:93:1: error: stray '\237' in program aceeasi_paritate.cpp:93:1: error: stray '\247' in program aceeasi_paritate.cpp:93:1: error: stray '\240' in program aceeasi_paritate.cpp:96:1: error: stray '\342' in program If same parity → inserts their average between them ^ aceeasi_paritate.cpp:96:1: error: stray '\206' in program aceeasi_paritate.cpp:96:1: error: stray '\222' in program aceeasi_paritate.cpp:102:1: error: stray '\360' in program 💡 Example ^ aceeasi_paritate.cpp:102:1: error: stray '\237' in program aceeasi_paritate.cpp:102:1: error: stray '\222' in program aceeasi_paritate.cpp:102:1: error: stray '\241' in program aceeasi_paritate.cpp:140:1: error: stray '\342' in program You’re very close now—this version fixes the biggest earlier issue (using a to store the original v[i+1]). 👍 ^ aceeasi_paritate.cpp:140:1: error: stray '\200' in program aceeasi_paritate.cpp:140:1: error: stray '\231' in program aceeasi_paritate.cpp:140:1: error: stray '\342' in program aceeasi_paritate.cpp:140:1: error: stray '\200' in program aceeasi_paritate.cpp:140:1: error: stray '\224' in program aceeasi_paritate.cpp:140:1: error: stray '\360' in program aceeasi_paritate.cpp:140:1: error: stray '\237' in program aceeasi_paritate.cpp:140:1: error: stray '\221' in program aceeasi_paritate.cpp:140:1: error: stray '\215' in program aceeasi_paritate.cpp:141:1: error: stray '\342' in program But there’s still one subtle bug left. ^ aceeasi_paritate.cpp:141:1: error: stray '\200' in program aceeasi_paritate.cpp:141:1: error: stray '\231' in program aceeasi_paritate.cpp:143:1: error: stray '\360' in program 🔴 Remaining Problem ^ aceeasi_paritate.cpp:143:1: error: stray '\237' in program aceeasi_paritate.cpp:143:1: error: stray '\224' in program aceeasi_paritate.cpp:143:1: error: stray '\264' in program aceeasi_paritate.cpp:153:1: error: stray '\360' in program 👉 It also shifts v[i], which you actually want to keep in place. ^ aceeasi_paritate.cpp:153:1: error: stray '\237' in program aceeasi_paritate.cpp:153:1: error: stray '\221' in program aceeasi_paritate.cpp:153:1: error: stray '\211' in program aceeasi_paritate.cpp:155:1: error: stray '\342' in program ✅ Correct fix ^ aceeasi_paritate.cpp:155:1: error: stray '\234' in program aceeasi_paritate.cpp:155:1: error: stray '\205' in program aceeasi_paritate.cpp:162:1: error: stray '\342' in program ✅ Fully corrected version ^ aceeasi_paritate.cpp:162:1: error: stray '\234' in program aceeasi_paritate.cpp:162:1: error: stray '\205' in program aceeasi_paritate.cpp:29:1: error: 'Your' does not name a type Your C++ program reads an array and inserts a new value between two consecutive elements if they have the same parity (both even or both odd). The inserted value is the average of neighbors. ^ aceeasi_paritate.cpp:43:1: error: 'But' does not name a type But after shifting, v[i+2] is not the original next element anymore. ^ aceeasi_paritate.cpp:51:1: error: 'But' does not name a type But you increase n → possible overflow. ^ aceeasi_paritate.cpp: In function 'int main()': aceeasi_paritate.cpp:62:5: error: redefinition of 'int main()' int main() ^ aceeasi_paritate.cpp:4:5: error: 'int main()' previously defined here int main() ^ aceeasi_paritate.cpp: At global scope: aceeasi_paritate.cpp:93:6: error: 'What' does not name a type 🧠 What it does now ^ aceeasi_paritate.cpp: In function 'int main()': aceeasi_paritate.cpp:115:5: error: redefinition of 'int main()' int main() ^ aceeasi_paritate.cpp:4:5: error: 'int main()' previously defined here int main() ^ aceeasi_paritate.cpp: At global scope: aceeasi_paritate.cpp:140:1: error: 'You' does not name a type You’re very close now—this version fixes the biggest earlier issue (using a to store the original v[i+1]). 👍 ^ aceeasi_paritate.cpp:147:12: error: 'j' does not name a type for(j = n; j >= i; j--) ^ aceeasi_paritate.cpp:147:20: error: 'j' does not name a type for(j = n; j >= i; j--) ^ aceeasi_paritate.cpp:151:1: error: 'This' does not name a type This shifts too much. ^ aceeasi_paritate.cpp:158:12: error: 'j' does not name a type for(j = n; j >= i+1; j--) ^ aceeasi_paritate.cpp:158:22: error: 'j' does not name a type for(j = n; j >= i+1; j--) ^ aceeasi_paritate.cpp:162:5: error: 'Fully' does not name a type ✅ Fully corrected version ^ aceeasi_paritate.cpp: In function 'int main()': aceeasi_paritate.cpp:166:5: error: redefinition of 'int main()' int main() ^ aceeasi_paritate.cpp:4:5: error: 'int main()' previously defined here int main() ^
www.pbinfo.ro permite evaluarea a două tipuri de probleme:
Problema aceeasi_paritate 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ă.