#1093
Text
Ion Petre, ca oricare adolescent, este pasionat atât de jocuri, cât şi de informatică. Ultimul astfel de joc este acela de a elimina dintr-un text cuvinte astfel încât fiecare cuvânt rămas să fie urmat de un cuvânt care începe cu aceeaşi literă cu care se termină cuvântul precedent. Face excepţie de la această regulă numai ultimul cuvânt.
Ion Petre, ca oricare adolescent, este pasionat atât de jocuri, cât şi de informatică. Ultimul astfel de joc este acela de a elimina dintr-un text cuvinte astfel încât fiecare cuvânt rămas să fie urmat de un cuvânt care începe cu aceeaşi literă cu care se termină cuvântul precedent. Face excepţie de la această regulă numai ultimul cuvânt.
Pentru un text dat, se cere să se afişeze numărul de cuvinte din text, apoi numărul minim de cuvinte ce pot fi eliminate astfel încât în textul rămas orice cuvânt (cu excepţia ultimului) să se termine cu aceeaşi literă cu care începe cuvântul următor, iar în final să se afişeze cuvintele din text rămase după eliminare, fiecare cuvânt fiind afişat pe câte o linie.
Pentru un text dat, se cere să se afişeze numărul de cuvinte din text, apoi numărul minim de cuvinte ce pot fi eliminate astfel încât în textul rămas orice cuvânt (cu excepţia ultimului) să se termine cu aceeaşi literă cu care începe cuvântul următor, iar în final să se afişeze cuvintele din text rămase după eliminare, fiecare cuvânt fiind afişat pe câte o linie.
OJI 2010, Clasa a X-a
Problema | Text | Operații I/O |
text.in /text.out
|
---|---|---|---|
Limita timp | 0.1 secunde | Limita memorie |
Total: 2 MB
/
Stivă 1 MB
|
Id soluție | #49812031 | Utilizator | |
Fișier | text.c | Dimensiune | 1.52 KB |
Data încărcării | 15 Martie 2024, 15:43 | Scor / rezultat | Eroare de compilare |
text.c:1:7: warning: type defaults to 'int' in declaration of 'fi' [enabled by default] const fi='text.in';fo='text.out'; ^ text.c:1:10: warning: character constant too long for its type [enabled by default] const fi='text.in';fo='text.out'; ^ text.c:1:20: warning: data definition has no type or storage class [enabled by default] const fi='text.in';fo='text.out'; ^ text.c:1:20: warning: type defaults to 'int' in declaration of 'fo' [enabled by default] text.c:1:23: warning: character constant too long for its type [enabled by default] const fi='text.in';fo='text.out'; ^ text.c:2:1: error: unknown type name 'var' var cuv:array[0..20000]of string[20]; ^ text.c:2:8: error: expected '=', ',', ';', 'asm' or '__attribute__' before ':' token var cuv:array[0..20000]of string[20]; ^ text.c:2:15: error: too many decimal points in number var cuv:array[0..20000]of string[20]; ^ text.c:3:5: warning: data definition has no type or storage class [enabled by default] l,p:array[0..20000]of integer; ^ text.c:3:5: warning: type defaults to 'int' in declaration of 'l' [enabled by default] text.c:3:8: error: expected '=', ',', ';', 'asm' or '__attribute__' before ':' token l,p:array[0..20000]of integer; ^ text.c:3:15: error: too many decimal points in number l,p:array[0..20000]of integer; ^ text.c:4:5: warning: data definition has no type or storage class [enabled by default] lmax,pmax:array['a'..'z']of integer; ^ text.c:4:5: warning: type defaults to 'int' in declaration of 'lmax' [enabled by default] text.c:4:14: error: expected '=', ',', ';', 'asm' or '__attribute__' before ':' token lmax,pmax:array['a'..'z']of integer; ^ text.c:5:5: warning: data definition has no type or storage class [enabled by default] ncuv,lsol,psol:integer; ^ text.c:5:5: warning: type defaults to 'int' in declaration of 'ncuv' [enabled by default] text.c:5:10: warning: type defaults to 'int' in declaration of 'lsol' [enabled by default] ncuv,lsol,psol:integer; ^ text.c:5:19: error: expected '=', ',', ';', 'asm' or '__attribute__' before ':' token ncuv,lsol,psol:integer; ^ text.c:6:8: error: expected '=', ',', ';', 'asm' or '__attribute__' before ':' token lit:char; ^ text.c:7:1: error: unknown type name 'procedure' procedure citire; ^ text.c:8:1: error: unknown type name 'var' var f:text; ^ text.c:8:6: error: expected '=', ',', ';', 'asm' or '__attribute__' before ':' token var f:text; ^ text.c:9:6: error: expected '=', ',', ';', 'asm' or '__attribute__' before ':' token s:string; ^ text.c:10:6: error: expected '=', ',', ';', 'asm' or '__attribute__' before ':' token i:byte; ^ text.c:11:1: error: unknown type name 'begin' begin ^ text.c:12:5: warning: parameter names (without types) in function declaration [enabled by default] assign(f,fi);reset(f); ^ text.c:12:18: warning: data definition has no type or storage class [enabled by default] assign(f,fi);reset(f); ^ text.c:12:18: warning: type defaults to 'int' in declaration of 'reset' [enabled by default] text.c:12:5: warning: parameter names (without types) in function declaration [enabled by default] assign(f,fi);reset(f); ^ text.c:13:9: error: expected '=', ',', ';', 'asm' or '__attribute__' before ':' token ncuv:=0; ^ text.c:14:5: error: expected identifier or '(' before 'while' while not seekeof(f) do begin ^ text.c:16:9: error: expected identifier or '(' before 'if' if s='' then continue; ^ text.c:16:14: error: empty character constant if s='' then continue; ^ text.c:17:9: error: expected identifier or '(' before 'while' while s[1]=' ' do delete(s,1,1); ^ text.c:18:9: error: expected identifier or '(' before 'while' while s[length(s)]=' ' do delete(s,length(s),1); ^ text.c:19:10: error: expected '=', ',', ';', 'asm' or '__attribute__' before ':' token i:=pos(' ',s); ^ text.c:20:9: error: expected identifier or '(' before 'while' while i<>0 do begin ^ text.c:22:24: error: expected '=', ',', ';', 'asm' or '__attribute__' before ':' token cuv[ncuv]:=copy(s,1,i-1); ^ text.c:23:24: error: expected ')' before numeric constant delete(s,1,i); ^ text.c:24:16: error: expected '=', ',', ';', 'asm' or '__attribute__' before ':' token i:=pos(' ',s) ^ text.c:26:9: warning: data definition has no type or storage class [enabled by default] inc(ncuv);cuv[ncuv]:=s ^ text.c:26:9: warning: type defaults to 'int' in declaration of 'inc' [enabled by default] text.c:26:9: warning: parameter names (without types) in function declaration [enabled by default] text.c:26:28: error: expected '=', ',', ';', 'asm' or '__attribute__' before ':' token inc(ncuv);cuv[ncuv]:=s ^ text.c:28:5: warning: return type defaults to 'int' [enabled by default] close(f) ^ text.c: In function 'close': text.c:29:1: error: expected declaration specifiers before 'end' end; ^ text.c:30:1: error: unknown type name 'procedure' procedure dinamica; ^ text.c:31:1: error: unknown type name 'var' var i:integer; ^ text.c:31:6: error: expected '=', ',', ';', 'asm' or '__attribute__' before ':' token var i:integer; ^ text.c:32:1: error: expected declaration specifiers before 'begin' begin ^ text.c:35:7: error: expected declaration specifiers before 'l' l[i]:=lmax[lit]+1; ^ text.c:36:7: error: expected declaration specifiers before 'p' p[i]:=pmax[lit]; ^ text.c:37:7: error: expected declaration specifiers before 'lit' lit:=cuv[i][length(cuv[i])]; ^ text.c:38:7: error: expected declaration specifiers before 'if' if l[i]>lmax[lit] then begin ^ text.c:40:9: error: expected declaration specifiers before 'pmax' pmax[lit]:=i ^ text.c:43:3: error: expected declaration specifiers before 'lsol' lsol:=0; ^ text.c:44:3: error: expected declaration specifiers before 'for' for lit:='a' to 'z' do ^ text.c:47:9: error: expected declaration specifiers before 'psol' psol:=pmax[lit] ^ text.c:50:1: error: unknown type name 'procedure' procedure scriere; ^ text.c:51:1: error: unknown type name 'var' var f:text; ^ text.c:51:6: error: expected '=', ',', ';', 'asm' or '__attribute__' before ':' token var f:text; ^ text.c:52:5: error: expected declaration specifiers before 'i' i:integer; ^ text.c:53:1: error: unknown type name 'begin' begin ^ text.c:54:4: warning: parameter names (without types) in function declaration [enabled by default] assign(f,fo);rewrite(f); ^ text.c:54:17: error: expected declaration specifiers before 'rewrite' assign(f,fo);rewrite(f); ^ text.c:55:4: error: expected declaration specifiers before 'writeln' writeln(f,ncuv,' ',ncuv-lsol); ^ text.c:56:4: error: expected declaration specifiers before 'i' i:=psol; ^ text.c:57:4: error: expected declaration specifiers before 'while' while p[i]<> 0 do begin ^ text.c:59:6: error: expected declaration specifiers before 'i' i:=p[i]; ^ text.c:60:4: error: expected declaration specifiers before 'end' end; ^ text.c:61:4: error: expected declaration specifiers before 'while' while i<>psol do begin ^ text.c:63:9: error: expected declaration specifiers before 'i' i:=l[i] ^ text.c:65:4: error: expected declaration specifiers before 'writeln' writeln(f,cuv[psol]); ^ text.c:66:4: error: expected declaration specifiers before 'close' close(f) ^ text.c:68:1: error: unknown type name 'begin' begin ^ text.c:70:3: error: expected declaration specifiers before 'dinamica' dinamica; ^ text.c:71:3: error: expected declaration specifiers before 'scriere' scriere ^ text.c:28:5: warning: type of 'f' defaults to 'int' [enabled by default] close(f) ^ text.c:69:3: error: declaration for parameter 'citire' but no such parameter citire; ^ text.c:54:4: error: declaration for parameter 'assign' but no such parameter assign(f,fo);rewrite(f); ^ text.c:50:11: error: declaration for parameter 'scriere' but no such parameter procedure scriere; ^ text.c:30:11: error: declaration for parameter 'dinamica' but no such parameter procedure dinamica; ^ text.c:71:3: warning: control reaches end of non-void function [-Wreturn-type] scriere ^
www.pbinfo.ro permite evaluarea a două tipuri de probleme:
Problema Text 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ă.