#1611
Palindrom2
Un număr se numește palindrom dacă prima lui cifră este egală cu ultima, a doua cu penultima și așa mai departe. De exemplu numerele 1221
, 505
și 7
sunt palindromuri, în vreme ce 500
, 1410
și 2424
nu sunt palindromuri.
Similar, un număr se numește aproape palindrom dacă are aceleași perechi de cifre identice ca un palindrom, mai puțin o pereche în care cifrele diferă. De exemplu numerele 500
, 1411
, 2444
, 1220
, 53625
, 14
și 4014
sunt numere aproape palindromuri, în vreme ce 1221
, 1410
, 6
, 505
, 22
și 512125
nu sunt numere aproape palindromuri deoarece fie sunt palindromuri, fie au prea multe perechi de cifre diferite.
Mai definim palindromul asociat al unui număr x
ca fiind cel mai mic număr palindrom p
strict mai mare decât x
(p>x
). De exemplu palindromul asociat al lui 5442
este 5445
, palindromul asociat al lui 2445
este 2552
, al lui 545
este 555
, al lui 39995
este 40004
, al lui 500
este 505
, iar al lui 512125
este 512215
.
Scrieţi un program care citind un număr natural nenul n
și apoi un șir de n numere naturale determină:
1. câte dintre cele n
numere sunt palindrom
2. câte dintre cele n
numere sunt aproape palindrom
3. palindromurile asociate pentru cele n
numere citite.
OJI 2016, Clasa a V-a
Problema | Palindrom2 | Operații I/O |
palindrom2.in /palindrom2.out
|
---|---|---|---|
Limita timp | 0.5 secunde | Limita memorie |
Total: 32 MB
/
Stivă 8 MB
|
Id soluție | #49286861 | Utilizator | |
Fișier | palindrom2.cpp | Dimensiune | 1.27 KB |
Data încărcării | 24 Februarie 2024, 09:22 | Scor / rezultat | Eroare de compilare |
palindrom2.cpp:8:1: error: stray '\302' in program unsigned long long x,ogl,copiex; ^ palindrom2.cpp:8:1: error: stray '\240' in program palindrom2.cpp:9:1: error: stray '\302' in program fin>>C; ^ palindrom2.cpp:9:1: error: stray '\240' in program palindrom2.cpp:10:1: error: stray '\302' in program fin>>n; ^ palindrom2.cpp:10:1: error: stray '\240' in program palindrom2.cpp:11:1: error: stray '\302' in program if(C==1)//daca cerinta este 1 trebuie sa numaram cate numere sunt palindrom ^ palindrom2.cpp:11:1: error: stray '\240' in program palindrom2.cpp:12:1: error: stray '\302' in program {for(i=1;i<=n;i++) ^ palindrom2.cpp:12:1: error: stray '\240' in program palindrom2.cpp:13:1: error: stray '\302' in program {fin>>x; ^ palindrom2.cpp:13:1: error: stray '\240' in program palindrom2.cpp:13:1: error: stray '\302' in program palindrom2.cpp:13:1: error: stray '\240' in program palindrom2.cpp:14:1: error: stray '\302' in program copiex=x; ^ palindrom2.cpp:14:1: error: stray '\240' in program palindrom2.cpp:14:1: error: stray '\302' in program palindrom2.cpp:14:1: error: stray '\240' in program palindrom2.cpp:15:1: error: stray '\302' in program ogl=0; ^ palindrom2.cpp:15:1: error: stray '\240' in program palindrom2.cpp:15:1: error: stray '\302' in program palindrom2.cpp:15:1: error: stray '\240' in program palindrom2.cpp:16:1: error: stray '\302' in program while(x!=0) ^ palindrom2.cpp:16:1: error: stray '\240' in program palindrom2.cpp:16:1: error: stray '\302' in program palindrom2.cpp:16:1: error: stray '\240' in program palindrom2.cpp:17:1: error: stray '\302' in program {cifra=x%10; ^ palindrom2.cpp:17:1: error: stray '\240' in program palindrom2.cpp:17:1: error: stray '\302' in program palindrom2.cpp:17:1: error: stray '\240' in program palindrom2.cpp:17:1: error: stray '\302' in program palindrom2.cpp:17:1: error: stray '\240' in program palindrom2.cpp:18:1: error: stray '\302' in program ogl=ogl*10+cifra; ^ palindrom2.cpp:18:1: error: stray '\240' in program palindrom2.cpp:18:1: error: stray '\302' in program palindrom2.cpp:18:1: error: stray '\240' in program palindrom2.cpp:18:1: error: stray '\302' in program palindrom2.cpp:18:1: error: stray '\240' in program palindrom2.cpp:19:1: error: stray '\302' in program x=x/10; ^ palindrom2.cpp:19:1: error: stray '\240' in program palindrom2.cpp:19:1: error: stray '\302' in program palindrom2.cpp:19:1: error: stray '\240' in program palindrom2.cpp:19:1: error: stray '\302' in program palindrom2.cpp:19:1: error: stray '\240' in program palindrom2.cpp:20:1: error: stray '\302' in program } ^ palindrom2.cpp:20:1: error: stray '\240' in program palindrom2.cpp:20:1: error: stray '\302' in program palindrom2.cpp:20:1: error: stray '\240' in program palindrom2.cpp:20:1: error: stray '\302' in program palindrom2.cpp:20:1: error: stray '\240' in program palindrom2.cpp:21:1: error: stray '\302' in program if(ogl==copiex) ^ palindrom2.cpp:21:1: error: stray '\240' in program palindrom2.cpp:21:1: error: stray '\302' in program palindrom2.cpp:21:1: error: stray '\240' in program palindrom2.cpp:22:1: error: stray '\302' in program k1++; ^ palindrom2.cpp:22:1: error: stray '\240' in program palindrom2.cpp:22:1: error: stray '\302' in program palindrom2.cpp:22:1: error: stray '\240' in program palindrom2.cpp:22:1: error: stray '\302' in program palindrom2.cpp:22:1: error: stray '\240' in program palindrom2.cpp:22:1: error: stray '\302' in program palindrom2.cpp:22:1: error: stray '\240' in program palindrom2.cpp:23:1: error: stray '\302' in program } ^ palindrom2.cpp:23:1: error: stray '\240' in program palindrom2.cpp:23:1: error: stray '\302' in program palindrom2.cpp:23:1: error: stray '\240' in program palindrom2.cpp:24:1: error: stray '\302' in program fout<<k1; ^ palindrom2.cpp:24:1: error: stray '\240' in program palindrom2.cpp:24:1: error: stray '\302' in program palindrom2.cpp:24:1: error: stray '\240' in program palindrom2.cpp:25:1: error: stray '\302' in program } ^ palindrom2.cpp:25:1: error: stray '\240' in program palindrom2.cpp:26:1: error: stray '\302' in program if(C==2) //daca cerinta este 1 trebuie sa numaram cate numere sunt aproape palindrom ^ palindrom2.cpp:26:1: error: stray '\240' in program palindrom2.cpp:27:1: error: stray '\302' in program {for(i=1;i<=n;i++) ^ palindrom2.cpp:27:1: error: stray '\240' in program palindrom2.cpp:28:1: error: stray '\302' in program {fin>>x; ^ palindrom2.cpp:28:1: error: stray '\240' in program palindrom2.cpp:28:1: error: stray '\302' in program palindrom2.cpp:28:1: error: stray '\240' in program palindrom2.cpp:29:1: error: stray '\302' in program copiex=x; ^ palindrom2.cpp:29:1: error: stray '\240' in program palindrom2.cpp:29:1: error: stray '\302' in program palindrom2.cpp:29:1: error: stray '\240' in program palindrom2.cpp:30:1: error: stray '\302' in program ogl=0; ^ palindrom2.cpp:30:1: error: stray '\240' in program palindrom2.cpp:30:1: error: stray '\302' in program palindrom2.cpp:30:1: error: stray '\240' in program palindrom2.cpp:31:1: error: stray '\302' in program nrcifre=0; ^ palindrom2.cpp:31:1: error: stray '\240' in program palindrom2.cpp:31:1: error: stray '\302' in program palindrom2.cpp:31:1: error: stray '\240' in program palindrom2.cpp:32:1: error: stray '\302' in program contor=0;//trebuie sa fie exact 1 ca nr sa fie aproape palindrom ^ palindrom2.cpp:32:1: error: stray '\240' in program palindrom2.cpp:32:1: error: stray '\302' in program palindrom2.cpp:32:1: error: stray '\240' in program palindrom2.cpp:33:1: error: stray '\302' in program while(x!=0) ^ palindrom2.cpp:33:1: error: stray '\240' in program palindrom2.cpp:33:1: error: stray '\302' in program palindrom2.cpp:33:1: error: stray '\240' in program palindrom2.cpp:34:1: error: stray '\302' in program {cifra=x%10; ^ palindrom2.cpp:34:1: error: stray '\240' in program palindrom2.cpp:34:1: error: stray '\302' in program palindrom2.cpp:34:1: error: stray '\240' in program palindrom2.cpp:34:1: error: stray '\302' in program palindrom2.cpp:34:1: error: stray '\240' in program palindrom2.cpp:35:1: error: stray '\302' in program nrcifre++;// numar cifrele ^ palindrom2.cpp:35:1: error: stray '\240' in program palindrom2.cpp:35:1: error: stray '\302' in program palindrom2.cpp:35:1: error: stray '\240' in program palindrom2.cpp:35:1: error: stray '\302' in program palindrom2.cpp:35:1: error: stray '\240' in program palindrom2.cpp:36:1: error: stray '\302' in program ogl=ogl*10+cifra; ^ palindrom2.cpp:36:1: error: stray '\240' in program palindrom2.cpp:36:1: error: stray '\302' in program palindrom2.cpp:36:1: error: stray '\240' in program palindrom2.cpp:36:1: error: stray '\302' in program palindrom2.cpp:36:1: error: stray '\240' in program palindrom2.cpp:37:1: error: stray '\302' in program x=x/10; ^ palindrom2.cpp:37:1: error: stray '\240' in program palindrom2.cpp:37:1: error: stray '\302' in program palindrom2.cpp:37:1: error: stray '\240' in program palindrom2.cpp:37:1: error: stray '\302' in program palindrom2.cpp:37:1: error: stray '\240' in program palindrom2.cpp:38:1: error: stray '\302' in program } //aici x=0 => va trebui sa folosesc copiex ^ palindrom2.cpp:38:1: error: stray '\240' in program palindrom2.cpp:38:1: error: stray '\302' in program palindrom2.cpp:38:1: error: stray '\240' in program palindrom2.cpp:38:1: error: stray '\302' in program palindrom2.cpp:38:1: error: stray '\240' in program palindrom2.cpp:39:1: error: stray '\302' in program for(int j=1;j<=nrcifre/2;j++) //ma opresc la jumatatea numarului de cifre ^ palindrom2.cpp:39:1: error: stray '\240' in program palindrom2.cpp:39:1: error: stray '\302' in program palindrom2.cpp:39:1: error: stray '\240' in program palindrom2.cpp:40:1: error: stray '\302' in program { ^ palindrom2.cpp:40:1: error: stray '\240' in program palindrom2.cpp:40:1: error: stray '\302' in program palindrom2.cpp:40:1: error: stray '\240' in program palindrom2.cpp:41:1: error: stray '\302' in program if(ogl%10!=copiex%10) contor++; ^ palindrom2.cpp:41:1: error: stray '\240' in program palindrom2.cpp:41:1: error: stray '\302' in program palindrom2.cpp:41:1: error: stray '\240' in program palindrom2.cpp:41:1: error: stray '\302' in program palindrom2.cpp:41:1: error: stray '\240' in program palindrom2.cpp:41:1: error: stray '\302' in program palindrom2.cpp:41:1: error: stray '\240' in program palindrom2.cpp:42:1: error: stray '\302' in program ogl=ogl/10; ^ palindrom2.cpp:42:1: error: stray '\240' in program palindrom2.cpp:42:1: error: stray '\302' in program palindrom2.cpp:42:1: error: stray '\240' in program palindrom2.cpp:42:1: error: stray '\302' in program palindrom2.cpp:42:1: error: stray '\240' in program palindrom2.cpp:42:1: error: stray '\302' in program palindrom2.cpp:42:1: error: stray '\240' in program palindrom2.cpp:43:1: error: stray '\302' in program copiex=copiex/10; ^ palindrom2.cpp:43:1: error: stray '\240' in program palindrom2.cpp:43:1: error: stray '\302' in program palindrom2.cpp:43:1: error: stray '\240' in program palindrom2.cpp:43:1: error: stray '\302' in program palindrom2.cpp:43:1: error: stray '\240' in program palindrom2.cpp:43:1: error: stray '\302' in program palindrom2.cpp:43:1: error: stray '\240' in program palindrom2.cpp:44:1: error: stray '\302' in program } ^ palindrom2.cpp:44:1: error: stray '\240' in program palindrom2.cpp:44:1: error: stray '\302' in program palindrom2.cpp:44:1: error: stray '\240' in program palindrom2.cpp:45:1: error: stray '\302' in program if(contor==1) //adica numarul x a fost aproape palindrom ^ palindrom2.cpp:45:1: error: stray '\240' in program palindrom2.cpp:45:1: error: stray '\302' in program palindrom2.cpp:45:1: error: stray '\240' in program palindrom2.cpp:46:1: error: stray '\302' in program k2++; ^ palindrom2.cpp:46:1: error: stray '\240' in program palindrom2.cpp:46:1: error: stray '\302' in program palindrom2.cpp:46:1: error: stray '\240' in program palindrom2.cpp:46:1: error: stray '\302' in program palindrom2.cpp:46:1: error: stray '\240' in program palindrom2.cpp:46:1: error: stray '\302' in program palindrom2.cpp:46:1: error: stray '\240' in program palindrom2.cpp:47:1: error: stray '\302' in program } ^ palindrom2.cpp:47:1: error: stray '\240' in program palindrom2.cpp:47:1: error: stray '\302' in program palindrom2.cpp:47:1: error: stray '\240' in program palindrom2.cpp:48:1: error: stray '\302' in program fout<<k2; ^ palindrom2.cpp:48:1: error: stray '\240' in program palindrom2.cpp:48:1: error: stray '\302' in program palindrom2.cpp:48:1: error: stray '\240' in program palindrom2.cpp:49:1: error: stray '\302' in program } ^ palindrom2.cpp:49:1: error: stray '\240' in program
www.pbinfo.ro permite evaluarea a două tipuri de probleme:
Problema Palindrom2 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ă.