#2441
pereche descentrata
O pereche de cuvinte, unul cu număr par de litere, iar celălalt cu număr impar de litere, se numește descentrată dacă se poate obține cuvântul cu număr par de litere din celălalt, prin duplicarea caracterului din mijlocul acestuia. Să se determine dacă există perechi descentrate de cuvinte.
simulare bacalaureat 2018
Problema | pereche descentrata | Operații I/O | tastatură/ecran |
---|---|---|---|
Limita timp | 0.1 secunde | Limita memorie |
Total: 64 MB
/
Stivă 8 MB
|
Id soluție | #16233488 | Utilizator | |
Fișier | pereche_descentrata.cpp | Dimensiune | 804 B |
Data încărcării | 22 Iunie 2019, 12:00 | Scor / rezultat | Eroare de compilare |
pereche_descentrata.cpp: In function 'int main()': pereche_descentrata.cpp:13:12: warning: array subscript has type 'char' [-Wchar-subscripts] a[i]=p; ^ pereche_descentrata.cpp:13:13: error: invalid conversion from 'char*' to 'char' [-fpermissive] a[i]=p; ^ pereche_descentrata.cpp:17:25: warning: comparison between signed and unsigned integer expressions [-Wsign-compare] for(i=1; i<=strlen(s); i++) ^ pereche_descentrata.cpp:19:29: warning: comparison between signed and unsigned integer expressions [-Wsign-compare] for(j=i; j<=strlen(s); j++) ^ pereche_descentrata.cpp:21:26: warning: array subscript has type 'char' [-Wchar-subscripts] if(strlen(a[i])==strlen(a[j])-1 and strlen(a[i])%2!=0) ^ pereche_descentrata.cpp:21:26: error: invalid conversion from 'char' to 'const char*' [-fpermissive] In file included from /usr/include/c++/4.8/cstring:42:0, from pereche_descentrata.cpp:4: /usr/include/string.h:399:15: error: initializing argument 1 of 'size_t strlen(const char*)' [-fpermissive] extern size_t strlen (const char *__s) ^ pereche_descentrata.cpp:21:40: warning: array subscript has type 'char' [-Wchar-subscripts] if(strlen(a[i])==strlen(a[j])-1 and strlen(a[i])%2!=0) ^ pereche_descentrata.cpp:21:40: error: invalid conversion from 'char' to 'const char*' [-fpermissive] In file included from /usr/include/c++/4.8/cstring:42:0, from pereche_descentrata.cpp:4: /usr/include/string.h:399:15: error: initializing argument 1 of 'size_t strlen(const char*)' [-fpermissive] extern size_t strlen (const char *__s) ^ pereche_descentrata.cpp:21:59: warning: array subscript has type 'char' [-Wchar-subscripts] if(strlen(a[i])==strlen(a[j])-1 and strlen(a[i])%2!=0) ^ pereche_descentrata.cpp:21:59: error: invalid conversion from 'char' to 'const char*' [-fpermissive] In file included from /usr/include/c++/4.8/cstring:42:0, from pereche_descentrata.cpp:4: /usr/include/string.h:399:15: error: initializing argument 1 of 'size_t strlen(const char*)' [-fpermissive] extern size_t strlen (const char *__s) ^ pereche_descentrata.cpp:23:31: warning: array subscript has type 'char' [-Wchar-subscripts] x=strcat(x,a[i]+strlen(a[i])/2); ^ pereche_descentrata.cpp:23:43: warning: array subscript has type 'char' [-Wchar-subscripts] x=strcat(x,a[i]+strlen(a[i])/2); ^ pereche_descentrata.cpp:23:43: error: invalid conversion from 'char' to 'const char*' [-fpermissive] In file included from /usr/include/c++/4.8/cstring:42:0, from pereche_descentrata.cpp:4: /usr/include/string.h:399:15: error: initializing argument 1 of 'size_t strlen(const char*)' [-fpermissive] extern size_t strlen (const char *__s) ^ pereche_descentrata.cpp:23:32: error: invalid conversion from 'size_t {aka unsigned int}' to 'const char*' [-fpermissive] x=strcat(x,a[i]+strlen(a[i])/2); ^ In file included from /usr/include/features.h:374:0, from /usr/include/i386-linux-gnu/c++/4.8/bits/os_defines.h:39, from /usr/include/i386-linux-gnu/c++/4.8/bits/c++config.h:426, from /usr/include/c++/4.8/iostream:38, from pereche_descentrata.cpp:1: /usr/include/i386-linux-gnu/bits/string3.h:140:1: error: initializing argument 2 of 'char* strcat(char*, const char*)' [-fpermissive] __NTH (strcat (char *__restrict __dest, const char *__restrict __src)) ^ pereche_descentrata.cpp:23:18: error: incompatible types in assignment of 'char*' to 'char [105]' x=strcat(x,a[i]+strlen(a[i])/2); ^ pereche_descentrata.cpp:24:34: warning: null argument where non-null required (argument 2) [-Wnonnull] x=strcat(x+1,NULL); ^ pereche_descentrata.cpp:24:18: error: incompatible types in assignment of 'char*' to 'char [105]' x=strcat(x+1,NULL); ^ pereche_descentrata.cpp:25:31: warning: array subscript has type 'char' [-Wchar-subscripts] y=strcat(y,a[j]+strlen(a[j])/2-1); ^ pereche_descentrata.cpp:25:43: warning: array subscript has type 'char' [-Wchar-subscripts] y=strcat(y,a[j]+strlen(a[j])/2-1); ^ pereche_descentrata.cpp:25:43: error: invalid conversion from 'char' to 'const char*' [-fpermissive] In file included from /usr/include/c++/4.8/cstring:42:0, from pereche_descentrata.cpp:4: /usr/include/string.h:399:15: error: initializing argument 1 of 'size_t strlen(const char*)' [-fpermissive] extern size_t strlen (const char *__s) ^ pereche_descentrata.cpp:25:47: error: invalid conversion from 'size_t {aka unsigned int}' to 'const char*' [-fpermissive] y=strcat(y,a[j]+strlen(a[j])/2-1); ^ In file included from /usr/include/features.h:374:0, from /usr/include/i386-linux-gnu/c++/4.8/bits/os_defines.h:39, from /usr/include/i386-linux-gnu/c++/4.8/bits/c++config.h:426, from /usr/include/c++/4.8/iostream:38, from pereche_descentrata.cpp:1: /usr/include/i386-linux-gnu/bits/string3.h:140:1: error: initializing argument 2 of 'char* strcat(char*, const char*)' [-fpermissive] __NTH (strcat (char *__restrict __dest, const char *__restrict __src)) ^ pereche_descentrata.cpp:25:18: error: incompatible types in assignment of 'char*' to 'char [105]' y=strcat(y,a[j]+strlen(a[j])/2-1); ^ pereche_descentrata.cpp:26:34: warning: null argument where non-null required (argument 2) [-Wnonnull] y=strcat(y+2,NULL); ^ pereche_descentrata.cpp:26:18: error: incompatible types in assignment of 'char*' to 'char [105]' y=strcat(y+2,NULL); ^
www.pbinfo.ro permite evaluarea a două tipuri de probleme:
Problema pereche descentrata 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ă.