#2798
Echilibrat
C++
Un număr natural este numit echilibrat dacă suma cifrelor sale de pe poziții pare este un număr par, iar suma cifrelor sale de pe poziții impare este un număr impar. Pozițiile cifrelor sunt numerotate de la dreapta la stânga, astfel: cifra unităților este pe poziția 0
, cifra zecilor este pe poziția 1
ș.a.m.d.
Subprogramul echilibrat
are un singur parametru, n
, prin care primește un număr natural (n∈[10,10
9
]
). Subprogramul returnează valoarea 1
dacă n
este echilibrat sau valoarea 0
în caz contrar.
Scrieți definiţia completă a subprogramului.
Subiect Bacalaureat 2018, sesiunea specială
Problema | Echilibrat | Operații I/O | tastatură/ecran |
---|---|---|---|
Limita timp | 0.1 secunde | Limita memorie |
Total: 64 MB
/
Stivă 8 MB
|
Id soluție | #22087914 | Utilizator | |
Fișier | echilibrat.cpp | Dimensiune | 581 B |
Data încărcării | 25 Martie 2020, 08:50 | Scor / rezultat | Eroare de compilare |
echilibrat.cpp:8:1: error: stray '\302' in program int suma_pare=0,suma_impare=0,i,v[n],k=0,nr=0; ^ echilibrat.cpp:8:1: error: stray '\240' in program echilibrat.cpp:8:1: error: stray '\302' in program echilibrat.cpp:8:1: error: stray '\240' in program echilibrat.cpp:10:1: error: stray '\302' in program while(n) ^ echilibrat.cpp:10:1: error: stray '\240' in program echilibrat.cpp:10:1: error: stray '\302' in program echilibrat.cpp:10:1: error: stray '\240' in program echilibrat.cpp:12:1: error: stray '\302' in program { ^ echilibrat.cpp:12:1: error: stray '\240' in program echilibrat.cpp:12:1: error: stray '\302' in program echilibrat.cpp:12:1: error: stray '\240' in program echilibrat.cpp:14:1: error: stray '\302' in program v[k]=n%10; ^ echilibrat.cpp:14:1: error: stray '\240' in program echilibrat.cpp:14:1: error: stray '\302' in program echilibrat.cpp:14:1: error: stray '\240' in program echilibrat.cpp:14:1: error: stray '\302' in program echilibrat.cpp:14:1: error: stray '\240' in program echilibrat.cpp:14:1: error: stray '\302' in program echilibrat.cpp:14:1: error: stray '\240' in program echilibrat.cpp:16:1: error: stray '\302' in program k++; ^ echilibrat.cpp:16:1: error: stray '\240' in program echilibrat.cpp:16:1: error: stray '\302' in program echilibrat.cpp:16:1: error: stray '\240' in program echilibrat.cpp:16:1: error: stray '\302' in program echilibrat.cpp:16:1: error: stray '\240' in program echilibrat.cpp:16:1: error: stray '\302' in program echilibrat.cpp:16:1: error: stray '\240' in program echilibrat.cpp:18:1: error: stray '\302' in program n/=10; ^ echilibrat.cpp:18:1: error: stray '\240' in program echilibrat.cpp:18:1: error: stray '\302' in program echilibrat.cpp:18:1: error: stray '\240' in program echilibrat.cpp:18:1: error: stray '\302' in program echilibrat.cpp:18:1: error: stray '\240' in program echilibrat.cpp:18:1: error: stray '\302' in program echilibrat.cpp:18:1: error: stray '\240' in program echilibrat.cpp:20:1: error: stray '\302' in program } ^ echilibrat.cpp:20:1: error: stray '\240' in program echilibrat.cpp:20:1: error: stray '\302' in program echilibrat.cpp:20:1: error: stray '\240' in program echilibrat.cpp:22:1: error: stray '\302' in program for(i=k-1;i>-1;--i) ^ echilibrat.cpp:22:1: error: stray '\240' in program echilibrat.cpp:22:1: error: stray '\302' in program echilibrat.cpp:22:1: error: stray '\240' in program echilibrat.cpp:24:1: error: stray '\302' in program { ^ echilibrat.cpp:24:1: error: stray '\240' in program echilibrat.cpp:24:1: error: stray '\302' in program echilibrat.cpp:24:1: error: stray '\240' in program echilibrat.cpp:26:1: error: stray '\302' in program if(nr%2==0 || nr==0) ^ echilibrat.cpp:26:1: error: stray '\240' in program echilibrat.cpp:26:1: error: stray '\302' in program echilibrat.cpp:26:1: error: stray '\240' in program echilibrat.cpp:26:1: error: stray '\302' in program echilibrat.cpp:26:1: error: stray '\240' in program echilibrat.cpp:26:1: error: stray '\302' in program echilibrat.cpp:26:1: error: stray '\240' in program echilibrat.cpp:28:1: error: stray '\302' in program { ^ echilibrat.cpp:28:1: error: stray '\240' in program echilibrat.cpp:28:1: error: stray '\302' in program echilibrat.cpp:28:1: error: stray '\240' in program echilibrat.cpp:28:1: error: stray '\302' in program echilibrat.cpp:28:1: error: stray '\240' in program echilibrat.cpp:28:1: error: stray '\302' in program echilibrat.cpp:28:1: error: stray '\240' in program echilibrat.cpp:30:1: error: stray '\302' in program suma_impare+=v[i]; ^ echilibrat.cpp:30:1: error: stray '\240' in program echilibrat.cpp:30:1: error: stray '\302' in program echilibrat.cpp:30:1: error: stray '\240' in program echilibrat.cpp:30:1: error: stray '\302' in program echilibrat.cpp:30:1: error: stray '\240' in program echilibrat.cpp:30:1: error: stray '\302' in program echilibrat.cpp:30:1: error: stray '\240' in program echilibrat.cpp:30:1: error: stray '\302' in program echilibrat.cpp:30:1: error: stray '\240' in program echilibrat.cpp:30:1: error: stray '\302' in program echilibrat.cpp:30:1: error: stray '\240' in program echilibrat.cpp:32:1: error: stray '\302' in program ++nr; ^ echilibrat.cpp:32:1: error: stray '\240' in program echilibrat.cpp:32:1: error: stray '\302' in program echilibrat.cpp:32:1: error: stray '\240' in program echilibrat.cpp:32:1: error: stray '\302' in program echilibrat.cpp:32:1: error: stray '\240' in program echilibrat.cpp:32:1: error: stray '\302' in program echilibrat.cpp:32:1: error: stray '\240' in program echilibrat.cpp:32:1: error: stray '\302' in program echilibrat.cpp:32:1: error: stray '\240' in program echilibrat.cpp:32:1: error: stray '\302' in program echilibrat.cpp:32:1: error: stray '\240' in program echilibrat.cpp:34:1: error: stray '\302' in program } ^ echilibrat.cpp:34:1: error: stray '\240' in program echilibrat.cpp:34:1: error: stray '\302' in program echilibrat.cpp:34:1: error: stray '\240' in program echilibrat.cpp:34:1: error: stray '\302' in program echilibrat.cpp:34:1: error: stray '\240' in program echilibrat.cpp:34:1: error: stray '\302' in program echilibrat.cpp:34:1: error: stray '\240' in program echilibrat.cpp:36:1: error: stray '\302' in program else ^ echilibrat.cpp:36:1: error: stray '\240' in program echilibrat.cpp:36:1: error: stray '\302' in program echilibrat.cpp:36:1: error: stray '\240' in program echilibrat.cpp:36:1: error: stray '\302' in program echilibrat.cpp:36:1: error: stray '\240' in program echilibrat.cpp:36:1: error: stray '\302' in program echilibrat.cpp:36:1: error: stray '\240' in program echilibrat.cpp:38:1: error: stray '\302' in program { ^ echilibrat.cpp:38:1: error: stray '\240' in program echilibrat.cpp:38:1: error: stray '\302' in program echilibrat.cpp:38:1: error: stray '\240' in program echilibrat.cpp:38:1: error: stray '\302' in program echilibrat.cpp:38:1: error: stray '\240' in program echilibrat.cpp:38:1: error: stray '\302' in program echilibrat.cpp:38:1: error: stray '\240' in program echilibrat.cpp:40:1: error: stray '\302' in program suma_pare+=v[i]; ^ echilibrat.cpp:40:1: error: stray '\240' in program echilibrat.cpp:40:1: error: stray '\302' in program echilibrat.cpp:40:1: error: stray '\240' in program echilibrat.cpp:40:1: error: stray '\302' in program echilibrat.cpp:40:1: error: stray '\240' in program echilibrat.cpp:40:1: error: stray '\302' in program echilibrat.cpp:40:1: error: stray '\240' in program echilibrat.cpp:40:1: error: stray '\302' in program echilibrat.cpp:40:1: error: stray '\240' in program echilibrat.cpp:40:1: error: stray '\302' in program echilibrat.cpp:40:1: error: stray '\240' in program echilibrat.cpp:42:1: error: stray '\302' in program ++nr; ^ echilibrat.cpp:42:1: error: stray '\240' in program echilibrat.cpp:42:1: error: stray '\302' in program echilibrat.cpp:42:1: error: stray '\240' in program echilibrat.cpp:42:1: error: stray '\302' in program echilibrat.cpp:42:1: error: stray '\240' in program echilibrat.cpp:42:1: error: stray '\302' in program echilibrat.cpp:42:1: error: stray '\240' in program echilibrat.cpp:42:1: error: stray '\302' in program echilibrat.cpp:42:1: error: stray '\240' in program echilibrat.cpp:42:1: error: stray '\302' in program echilibrat.cpp:42:1: error: stray '\240' in program echilibrat.cpp:44:1: error: stray '\302' in program } ^ echilibrat.cpp:44:1: error: stray '\240' in program echilibrat.cpp:44:1: error: stray '\302' in program echilibrat.cpp:44:1: error: stray '\240' in program echilibrat.cpp:44:1: error: stray '\302' in program echilibrat.cpp:44:1: error: stray '\240' in program echilibrat.cpp:44:1: error: stray '\302' in program echilibrat.cpp:44:1: error: stray '\240' in program echilibrat.cpp:46:1: error: stray '\302' in program } ^ echilibrat.cpp:46:1: error: stray '\240' in program echilibrat.cpp:46:1: error: stray '\302' in program echilibrat.cpp:46:1: error: stray '\240' in program echilibrat.cpp:48:1: error: stray '\302' in program if(suma_impare%2==1 && suma_pare%2==0) ^ echilibrat.cpp:48:1: error: stray '\240' in program echilibrat.cpp:48:1: error: stray '\302' in program echilibrat.cpp:48:1: error: stray '\240' in program echilibrat.cpp:50:1: error: stray '\302' in program return 1; ^ echilibrat.cpp:50:1: error: stray '\240' in program echilibrat.cpp:50:1: error: stray '\302' in program echilibrat.cpp:50:1: error: stray '\240' in program echilibrat.cpp:52:1: error: stray '\302' in program return 0; ^ echilibrat.cpp:52:1: error: stray '\240' in program echilibrat.cpp:52:1: error: stray '\302' in program echilibrat.cpp:52:1: error: stray '\240' in program
www.pbinfo.ro permite evaluarea a două tipuri de probleme:
Problema Echilibrat 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ă.