#135
Să se scrie un program care determină cel mai bun șablon comun a două șiruri de caractere.
Variante Bacalaureat 2009
| Problema | Sablon | Operații I/O |
tastatură/ecran
|
|---|---|---|---|
| Limita timp | 0.1 secunde | Limita memorie |
Total: 64 MB
/
Stivă 8 MB
|
| Id soluție | #64334065 | Utilizator | |
| Fișier | sablon.cpp | Dimensiune | 430 B |
| Data încărcării | 30 Aprilie 2026, 10:24 | Scor/rezultat | Eroare de compilare |
sablon.cpp: In function ‘int main()’: sablon.cpp:9:19: warning: comparison of integer expressions of different signedness: ‘int’ and ‘size_t’ {aka ‘long unsigned int’} [-Wsign-compare] 9 | for(int i=0; i<strlen(s); i++){ | ~^~~~~~~~~~ sablon.cpp:10:18: error: no matching function for call to ‘strchr(char&, const char [6])’ 10 | if(strchr(s[i],"aeiou")==1 && strchr(t[i],"aeiou")==1) | ~~~~~~^~~~~~~~~~~~~~ In file included from /usr/include/c++/13/cstring:42, from sablon.cpp:2: /usr/include/string.h:239:1: note: candidate: ‘const char* strchr(const char*, int)’ (near match) 239 | strchr (const char *__s, int __c) __THROW | ^~~~~~ /usr/include/string.h:239:1: note: conversion of argument 2 would be ill-formed: sablon.cpp:10:24: error: invalid conversion from ‘const char*’ to ‘int’ [-fpermissive] 10 | if(strchr(s[i],"aeiou")==1 && strchr(t[i],"aeiou")==1) | ^~~~~~~ | | | const char* /usr/include/string.h:233:1: note: candidate: ‘char* strchr(char*, int)’ (near match) 233 | strchr (char *__s, int __c) __THROW | ^~~~~~ /usr/include/string.h:233:1: note: conversion of argument 2 would be ill-formed: sablon.cpp:10:24: error: invalid conversion from ‘const char*’ to ‘int’ [-fpermissive] 10 | if(strchr(s[i],"aeiou")==1 && strchr(t[i],"aeiou")==1) | ^~~~~~~ | | | const char* sablon.cpp:10:45: error: no matching function for call to ‘strchr(char&, const char [6])’ 10 | if(strchr(s[i],"aeiou")==1 && strchr(t[i],"aeiou")==1) | ~~~~~~^~~~~~~~~~~~~~ /usr/include/string.h:239:1: note: candidate: ‘const char* strchr(const char*, int)’ (near match) 239 | strchr (const char *__s, int __c) __THROW | ^~~~~~ /usr/include/string.h:239:1: note: conversion of argument 2 would be ill-formed: sablon.cpp:10:51: error: invalid conversion from ‘const char*’ to ‘int’ [-fpermissive] 10 | if(strchr(s[i],"aeiou")==1 && strchr(t[i],"aeiou")==1) | ^~~~~~~ | | | const char* /usr/include/string.h:233:1: note: candidate: ‘char* strchr(char*, int)’ (near match) 233 | strchr (char *__s, int __c) __THROW | ^~~~~~ /usr/include/string.h:233:1: note: conversion of argument 2 would be ill-formed: sablon.cpp:10:51: error: invalid conversion from ‘const char*’ to ‘int’ [-fpermissive] 10 | if(strchr(s[i],"aeiou")==1 && strchr(t[i],"aeiou")==1) | ^~~~~~~ | | | const char* sablon.cpp:12:23: error: no matching function for call to ‘strchr(char&, const char [6])’ 12 | else if(strchr(s[i],"aeiou")==0 && strchr(t[i],"aeiou")==0) | ~~~~~~^~~~~~~~~~~~~~ /usr/include/string.h:239:1: note: candidate: ‘const char* strchr(const char*, int)’ (near match) 239 | strchr (const char *__s, int __c) __THROW | ^~~~~~ /usr/include/string.h:239:1: note: conversion of argument 2 would be ill-formed: sablon.cpp:12:29: error: invalid conversion from ‘const char*’ to ‘int’ [-fpermissive] 12 | else if(strchr(s[i],"aeiou")==0 && strchr(t[i],"aeiou")==0) | ^~~~~~~ | | | const char* /usr/include/string.h:233:1: note: candidate: ‘char* strchr(char*, int)’ (near match) 233 | strchr (char *__s, int __c) __THROW | ^~~~~~ /usr/include/string.h:233:1: note: conversion of argument 2 would be ill-formed: sablon.cpp:12:29: error: invalid conversion from ‘const char*’ to ‘int’ [-fpermissive] 12 | else if(strchr(s[i],"aeiou")==0 && strchr(t[i],"aeiou")==0) | ^~~~~~~ | | | const char* sablon.cpp:12:50: error: no matching function for call to ‘strchr(char&, const char [6])’ 12 | else if(strchr(s[i],"aeiou")==0 && strchr(t[i],"aeiou")==0) | ~~~~~~^~~~~~~~~~~~~~ /usr/include/string.h:239:1: note: candidate: ‘const char* strchr(const char*, int)’ (near match) 239 | strchr (const char *__s, int __c) __THROW | ^~~~~~ /usr/include/string.h:239:1: note: conversion of argument 2 would be ill-formed: sablon.cpp:12:56: error: invalid conversion from ‘const char*’ to ‘int’ [-fpermissive] 12 | else if(strchr(s[i],"aeiou")==0 && strchr(t[i],"aeiou")==0) | ^~~~~~~ | | | const char* /usr/include/string.h:233:1: note: candidate: ‘char* strchr(char*, int)’ (near match) 233 | strchr (char *__s, int __c) __THROW | ^~~~~~ /usr/include/string.h:233:1: note: conversion of argument 2 would be ill-formed: sablon.cpp:12:56: error: invalid conversion from ‘const char*’ to ‘int’ [-fpermissive] 12 | else if(strchr(s[i],"aeiou")==0 && strchr(t[i],"aeiou")==0) | ^~~~~~~ | | | const char*
www.pbinfo.ro permite evaluarea a două tipuri de probleme:
Problema Sablon 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ă.