#2997
prescurtat
C++
Scrieți funcția cu următorul antet:
void Prescurtat(char s[])
Funcția primește ca parametru un text de cel mult 50
de caractere, alcătuit din cuvinte separate prin câte un spațiu și formate din litere mari ale alfabetului englez, urmate eventual de caracterul .
(punct), dacă sunt scrise prescurtat. Textul reprezintă numele unei instituții de învățământ și doar cuvintele din mulțimea {COLEGIUL
, LICEUL
, NATIONAL
, TEORETIC
} pot fi prescurtate, eliminându-se ultimele lor litere. Funcția va returna tot prin intermediul parametrului s
numele instituției scris fără prescurtări.
Simulare bacalaureat 2019
Problema | prescurtat | Operații I/O |
prescurtat.in /prescurtat.out
|
---|---|---|---|
Limita timp | 0.1 secunde | Limita memorie |
Total: 64 MB
/
Stivă 8 MB
|
Id soluție | #52552401 | Utilizator | |
Fișier | prescurtat.cpp | Dimensiune | 1.08 KB |
Data încărcării | 03 Octombrie 2024, 08:22 | Scor / rezultat | Eroare de compilare |
prescurtat.cpp:17:56: warning: character constant too long for its type [enabled by default] if ((p[lcuv-1]=='.')&&(p[0]=='C'))strcat(sirfinal, 'COLEGIUL'); ^ prescurtat.cpp:18:61: warning: character constant too long for its type [enabled by default] else if ((p[lcuv-1]=='.')&&(p[0]=='L'))strcat(sirfinal, 'LICEUL'); ^ prescurtat.cpp:19:61: warning: character constant too long for its type [enabled by default] else if ((p[lcuv-1]=='.')&&(p[0]=='N'))strcat(sirfinal, 'NATIONAL'); ^ prescurtat.cpp:20:61: warning: character constant too long for its type [enabled by default] else if ((p[lcuv-1]=='.')&&(p[0]=='T'))strcat(sirfinal, 'TEORETIC'); ^ prescurtat.cpp: In function 'void Prescurtat(char*)': prescurtat.cpp:17:66: error: invalid conversion from 'int' to 'const char*' [-fpermissive] if ((p[lcuv-1]=='.')&&(p[0]=='C'))strcat(sirfinal, 'COLEGIUL'); ^ 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/iosfwd:38, from /usr/include/c++/4.8/ios:38, from /usr/include/c++/4.8/istream:38, from /usr/include/c++/4.8/fstream:38, from prescurtat.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)) ^ prescurtat.cpp:18:69: error: invalid conversion from 'int' to 'const char*' [-fpermissive] else if ((p[lcuv-1]=='.')&&(p[0]=='L'))strcat(sirfinal, 'LICEUL'); ^ 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/iosfwd:38, from /usr/include/c++/4.8/ios:38, from /usr/include/c++/4.8/istream:38, from /usr/include/c++/4.8/fstream:38, from prescurtat.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)) ^ prescurtat.cpp:19:71: error: invalid conversion from 'int' to 'const char*' [-fpermissive] else if ((p[lcuv-1]=='.')&&(p[0]=='N'))strcat(sirfinal, 'NATIONAL'); ^ 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/iosfwd:38, from /usr/include/c++/4.8/ios:38, from /usr/include/c++/4.8/istream:38, from /usr/include/c++/4.8/fstream:38, from prescurtat.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)) ^ prescurtat.cpp:20:71: error: invalid conversion from 'int' to 'const char*' [-fpermissive] else if ((p[lcuv-1]=='.')&&(p[0]=='T'))strcat(sirfinal, 'TEORETIC'); ^ 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/iosfwd:38, from /usr/include/c++/4.8/ios:38, from /usr/include/c++/4.8/istream:38, from /usr/include/c++/4.8/fstream:38, from prescurtat.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)) ^ prescurtat.cpp:23:14: error: expected primary-expression before '=' token while (p!==NULL) ^ prescurtat.cpp:28:22: error: 'p' cannot be used as a function if ((p(lcuv-1)==".")&&(p[0]=="C"))strcat(sirfinal, "COLEGIUL"); ^ prescurtat.cpp:28:38: warning: comparison with string literal results in unspecified behaviour [-Waddress] if ((p(lcuv-1)==".")&&(p[0]=="C"))strcat(sirfinal, "COLEGIUL"); ^ prescurtat.cpp:28:38: error: ISO C++ forbids comparison between pointer and integer [-fpermissive] prescurtat.cpp:29:27: error: 'p' cannot be used as a function else if ((p(lcuv-1)==".")&&(p[0]=="L"))strcat(sirfinal, "LICEUL"); ^ prescurtat.cpp:29:43: warning: comparison with string literal results in unspecified behaviour [-Waddress] else if ((p(lcuv-1)==".")&&(p[0]=="L"))strcat(sirfinal, "LICEUL"); ^ prescurtat.cpp:29:43: error: ISO C++ forbids comparison between pointer and integer [-fpermissive] prescurtat.cpp:30:27: error: 'p' cannot be used as a function else if ((p(lcuv-1)==".")&&(p[0]=="N"))strcat(sirfinal, "NATIONAL"); ^ prescurtat.cpp:30:43: warning: comparison with string literal results in unspecified behaviour [-Waddress] else if ((p(lcuv-1)==".")&&(p[0]=="N"))strcat(sirfinal, "NATIONAL"); ^ prescurtat.cpp:30:43: error: ISO C++ forbids comparison between pointer and integer [-fpermissive] prescurtat.cpp:31:27: error: 'p' cannot be used as a function else if ((p(lcuv-1)==".")&&(p[0]=="T"))strcat(sirfinal, "TEORETIC"); ^ prescurtat.cpp:31:43: warning: comparison with string literal results in unspecified behaviour [-Waddress] else if ((p(lcuv-1)==".")&&(p[0]=="T"))strcat(sirfinal, "TEORETIC"); ^ prescurtat.cpp:31:43: error: ISO C++ forbids comparison between pointer and integer [-fpermissive] prescurtat.cpp: In function 'int main()': prescurtat.cpp:50:5: error: redefinition of 'int main()' int main() ^ prescurtat.cpp:38:5: error: 'int main()' previously defined here int main () ^
www.pbinfo.ro permite evaluarea a două tipuri de probleme:
Problema prescurtat face parte din a doua categorie. Pentru aceste probleme se folosește un program suport, furnizat de propunătorul problemei. 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ă.