#2997
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 | #64106869 | Utilizator | |
| Fișier | prescurtat.cpp | Dimensiune | 612 B |
| Data încărcării | 17 Aprilie 2026, 11:20 | Scor/rezultat | Eroare de compilare |
prescurtat.cpp:7:22: warning: missing terminating " character 7 | char cp[200]="", "p; | ^ prescurtat.cpp:7:22: error: missing terminating " character 7 | char cp[200]="", "p; | ^~~ prescurtat.cpp: In function ‘void Prescurtat(char*)’: prescurtat.cpp:9:13: error: invalid conversion from ‘char*’ to ‘char’ [-fpermissive] 9 | p=strtok(s, " "); | ~~~~~~^~~~~~~~ | | | char* prescurtat.cpp:12:18: error: no matching function for call to ‘strchr(char&, char)’ 12 | if(strchr(p,'.')) | ~~~~~~^~~~~~~ In file included from /usr/include/c++/13/cstring:42, from prescurtat.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 1 would be ill-formed: prescurtat.cpp:12:19: error: invalid conversion from ‘char’ to ‘const char*’ [-fpermissive] 12 | if(strchr(p,'.')) | ^ | | | 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 1 would be ill-formed: prescurtat.cpp:12:19: error: invalid conversion from ‘char’ to ‘char*’ [-fpermissive] 12 | if(strchr(p,'.')) | ^ | | | char prescurtat.cpp:14:17: error: invalid types ‘char[int]’ for array subscript 14 | if(p[0]=='C') | ^ prescurtat.cpp:15:17: error: ‘Strcat’ was not declared in this scope; did you mean ‘strcat’? 15 | Strcat(cp,"COLEGIUL "); | ^~~~~~ | strcat prescurtat.cpp:16:17: error: invalid types ‘char[int]’ for array subscript 16 | if(p[0]=='L') | ^ prescurtat.cpp:17:17: error: ‘Strcat’ was not declared in this scope; did you mean ‘strcat’? 17 | Strcat(cp,"LICEUL "); | ^~~~~~ | strcat prescurtat.cpp:16:13: warning: this ‘if’ clause does not guard... [-Wmisleading-indentation] 16 | if(p[0]=='L') | ^~ prescurtat.cpp:18:17: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the ‘if’ 18 | if(p[0]=='N') | ^~ prescurtat.cpp:18:21: error: invalid types ‘char[int]’ for array subscript 18 | if(p[0]=='N') | ^ prescurtat.cpp:19:17: error: ‘Strcat’ was not declared in this scope; did you mean ‘strcat’? 19 | Strcat(cp,"NATIONAL "); | ^~~~~~ | strcat prescurtat.cpp:20:21: error: invalid types ‘char[int]’ for array subscript 20 | if(p[0]=='T') | ^ prescurtat.cpp:21:17: error: ‘Strcat’ was not declared in this scope; did you mean ‘strcat’? 21 | Strcat(cp,"TEORETIC "); | ^~~~~~ | strcat prescurtat.cpp:25:23: error: invalid conversion from ‘char’ to ‘const char*’ [-fpermissive] 25 | strcat(cp,p); | ^ | | | char In file included from /usr/include/features.h:502, from /usr/include/x86_64-linux-gnu/c++/13/bits/os_defines.h:39, from /usr/include/x86_64-linux-gnu/c++/13/bits/c++config.h:679, from /usr/include/c++/13/bits/requires_hosted.h:31, from /usr/include/c++/13/fstream:38, from prescurtat.cpp:1: /usr/include/x86_64-linux-gnu/bits/string_fortified.h:128:1: note: initializing argument 2 of ‘char* strcat(char*, const char*)’ 128 | __NTH (strcat (char *__restrict __dest, const char *__restrict __src)) | ^~~~~ prescurtat.cpp:28:17: error: invalid conversion from ‘char*’ to ‘char’ [-fpermissive] 28 | p=strtok(NULL, " ") | ~~~~~~^~~~~~~~~~~ | | | char* prescurtat.cpp:28:28: error: expected ‘;’ before ‘}’ token 28 | p=strtok(NULL, " ") | ^ | ; 29 | } | ~ prescurtat.cpp:30:21: error: expected ‘)’ before ‘]’ token 30 | cp[strlen((cp)-1]= '\0'; | ~ ^ | )
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ă.