#3080
Se dă un șir de caractere. Sa se determine numărul scris cu cifrele existente în șirul dat. Să se afișeze numărul obținut și, pe linia următoare, toate caracterele din șir care nu fac parte din număr, cu excepția spațiilor.
| Problema | VerifNumar | Operații I/O |
tastatură/ecran
|
|---|---|---|---|
| Limita timp | 0.1 secunde | Limita memorie |
Total: 64 MB
/
Stivă 8 MB
|
| Id soluție | #64271196 | Utilizator | |
| Fișier | verifnumar.cpp | Dimensiune | 895 B |
| Data încărcării | 27 Aprilie 2026, 12:55 | Scor/rezultat | Eroare de compilare |
verifnumar.cpp: In function ‘int main()’: verifnumar.cpp:16:10: warning: comparison of integer expressions of different signedness: ‘int’ and ‘size_t’ {aka ‘long unsigned int’} [-Wsign-compare] 16 | while(i<strlen(s)){ | ~^~~~~~~~~~ verifnumar.cpp:18:14: error: no matching function for call to ‘strchr(char&, const char [11])’ 18 | if(strchr(s[i],"0123456789")==0){ | ~~~~~~^~~~~~~~~~~~~~~~~~~ In file included from /usr/include/c++/13/cstring:42, from verifnumar.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: verifnumar.cpp:18:20: error: invalid conversion from ‘const char*’ to ‘int’ [-fpermissive] 18 | if(strchr(s[i],"0123456789")==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: verifnumar.cpp:18:20: error: invalid conversion from ‘const char*’ to ‘int’ [-fpermissive] 18 | if(strchr(s[i],"0123456789")==0){ | ^~~~~~~~~~~~ | | | const char* verifnumar.cpp:21:11: error: ‘doar_0’ was not declared in this scope 21 | doar_0=false; | ^~~~~~ verifnumar.cpp:40:10: warning: comparison of integer expressions of different signedness: ‘int’ and ‘size_t’ {aka ‘long unsigned int’} [-Wsign-compare] 40 | while(i<strlen(s)){ | ~^~~~~~~~~~ verifnumar.cpp:42:14: error: no matching function for call to ‘strchr(char&, const char [11])’ 42 | if(strchr(s[i],"1234567890") && s[i]!='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: verifnumar.cpp:42:20: error: invalid conversion from ‘const char*’ to ‘int’ [-fpermissive] 42 | if(strchr(s[i],"1234567890") && s[i]!='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: verifnumar.cpp:42:20: error: invalid conversion from ‘const char*’ to ‘int’ [-fpermissive] 42 | if(strchr(s[i],"1234567890") && s[i]!='0'){ | ^~~~~~~~~~~~ | | | const char* verifnumar.cpp:61:10: warning: comparison of integer expressions of different signedness: ‘int’ and ‘size_t’ {aka ‘long unsigned int’} [-Wsign-compare] 61 | while(i<strlen(s)){ | ~^~~~~~~~~~ verifnumar.cpp:63:14: error: no matching function for call to ‘strchr(char&)’ 63 | if(strchr(s[i])) | ~~~~~~^~~~~~ /usr/include/string.h:233:1: note: candidate: ‘char* strchr(char*, int)’ 233 | strchr (char *__s, int __c) __THROW | ^~~~~~ /usr/include/string.h:233:1: note: candidate expects 2 arguments, 1 provided /usr/include/string.h:239:1: note: candidate: ‘const char* strchr(const char*, int)’ 239 | strchr (const char *__s, int __c) __THROW | ^~~~~~ /usr/include/string.h:239:1: note: candidate expects 2 arguments, 1 provided verifnumar.cpp:64:3: error: expected primary-expression before ‘}’ token 64 | } | ^ verifnumar.cpp:59:8: warning: unused variable ‘doar_chr’ [-Wunused-variable] 59 | bool doar_chr=true; | ^~~~~~~~
www.pbinfo.ro permite evaluarea a două tipuri de probleme:
Problema VerifNumar 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ă.