#846
Dubluri
Se dă un șir de caractere ce conține doar litere mici ale alfabetului englez. Să se afișeze cel mai lung subșir care apare de cel puțin două ori în șirul dat.
Problema | Dubluri | Operații I/O | tastatură/ecran |
---|---|---|---|
Limita timp | 0.1 secunde | Limita memorie |
Total: 64 MB
/
Stivă 8 MB
|
Id soluție | #52768502 | Utilizator | |
Fișier | dubluri.cpp | Dimensiune | 1.27 KB |
Data încărcării | 08 Octombrie 2024, 22:40 | Scor / rezultat | Eroare de compilare |
dubluri.cpp:6:23: error: 'charw' does not name a type int slice_count(const charw, const char slice); ^ dubluri.cpp:6:23: error: ISO C++ forbids declaration of 'parameter' with no type [-fpermissive] dubluri.cpp: In function 'char* slice(char, int, int)': dubluri.cpp:11:5: error: 'charr' was not declared in this scope charr = (char)malloc(sizeof(char) strlen(src)); ^ dubluri.cpp:11:39: error: expected ')' before 'strlen' charr = (char)malloc(sizeof(char) strlen(src)); ^ dubluri.cpp:11:50: error: cast from 'void*' to 'char' loses precision [-fpermissive] charr = (char)malloc(sizeof(char) strlen(src)); ^ dubluri.cpp:14:9: error: 'r' was not declared in this scope r[i++] = src[j]; ^ dubluri.cpp:14:23: error: invalid types 'const char[int]' for array subscript r[i++] = src[j]; ^ dubluri.cpp:15:5: error: 'r' was not declared in this scope r[i] = 0; ^ dubluri.cpp: At global scope: dubluri.cpp:19:37: error: 'charslice' does not name a type int slice_count(const char w, const charslice) ^ dubluri.cpp:19:37: error: ISO C++ forbids declaration of 'parameter' with no type [-fpermissive] dubluri.cpp: In function 'int slice_count(char, int)': dubluri.cpp:22:30: error: no matching function for call to 'strstr(const char&, char* (&)(char, int, int))' char *p = strstr(w, slice); ^ dubluri.cpp:22:30: note: candidates are: In file included from dubluri.cpp:2:0: /usr/include/string.h:329:1: note: char* strstr(char*, const char*) strstr (char *__haystack, const char *__needle) __THROW ^ /usr/include/string.h:329:1: note: no known conversion for argument 2 from 'char*(char, int, int)' to 'const char*' /usr/include/string.h:335:1: note: const char* strstr(const char*, const char*) strstr (const char *__haystack, const char *__needle) __THROW ^ /usr/include/string.h:335:1: note: no known conversion for argument 2 from 'char*(char, int, int)' to 'const char*' dubluri.cpp:25:36: error: cannot convert 'char* (*)(char, int, int)' to 'const char*' for argument '1' to 'size_t strlen(const char*)' p = strstr(p + strlen(slice), slice); ^ dubluri.cpp: In function 'int main()': dubluri.cpp:38:32: warning: comparison between signed and unsigned integer expressions [-Wsign-compare] for(int i = 0; i < strlen(s); i++) ^ dubluri.cpp:40:41: warning: comparison between signed and unsigned integer expressions [-Wsign-compare] for(int j = i + 1; j <= strlen(s); j++) ^ dubluri.cpp:42:13: error: 'charss' was not declared in this scope charss = slice(s, i, j); ^ dubluri.cpp:42:35: error: invalid conversion from 'char*' to 'char' [-fpermissive] charss = slice(s, i, j); ^ dubluri.cpp:9:7: error: initializing argument 1 of 'char* slice(char, int, int)' [-fpermissive] char* slice(const char src, int start, int end) ^ dubluri.cpp:43:23: error: 'ss' was not declared in this scope if(strlen(ss) == 1) ^ dubluri.cpp:45:52: error: 'ss' was not declared in this scope int de_cate_ori_apare = slice_count(s, ss); ^ dubluri.cpp:36:9: warning: unused variable 'de_cate_ori_apare_max' [-Wunused-variable] int de_cate_ori_apare_max = 0; ^ dubluri.cpp: In function 'char* slice(char, int, int)': dubluri.cpp:17:1: warning: control reaches end of non-void function [-Wreturn-type] } ^ dubluri.cpp: In function 'int main()': dubluri.cpp:35:19: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result] scanf("%s", s); ^
www.pbinfo.ro permite evaluarea a două tipuri de probleme:
Problema Dubluri 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ă.