program main;
const alpha= [ 'А' .. 'Я' , 'а' .. 'п' , 'р' .. 'я' ,
'.' , ',' , '-' , ':' , ';' , '?' ,
'!' , '"' ] ;
type T= array [ 1 .. 100 ] of string ;
type A= set of char ;
var i, j, k: integer ;
found, s, temp: string ;
n: integer ; {Количество прочитанных слов}
words: T; {Массив слов}
first: A; {Множество букв первого слова}
flag: boolean ;
procedure GetWords( s: string ; var a: T; var n: Integer ) ;
var _word: String ;
i: Integer ;
begin
i: = 1 ;
n: = 0 ;
s: = s+ ' ' ;
while i<length( s) do
if s[ i] in alpha then begin
_word: = '' ;
while ( s[ i] in alpha) and ( i<length( s) ) do begin
_word: = _word+ s[ i] ;
inc( i) ;
end ;
if _word <> ' ' then begin
inc( n) ;
a[ n] : = _word;
end ;
end
else inc( i) ;
a[ n] : = a[ n] + s[ i] ;
end ;
function up( s: string ) : string ;
var i: Integer ;
s1: string ;
begin
s1: = '' ;
for i: = 1 to length( s) do
case s[ i] of
'А' .. 'Я' : s1: = s1+ s[ i] ;
'а' .. 'п' : s1: = s1+ chr ( ord ( 'А' ) + ord ( s[ i] ) - ord ( 'а' ) ) ;
'р' .. 'я' : s1: = s1+ chr ( ord ( 'П' ) + ord ( s[ i] ) - ord ( 'п' ) ) ;
end ;
up: = s1;
end ;
begin
assign( input, 'input.txt' ) ;
reset( input) ;
assign( output, 'output.txt' ) ;
rewrite( output) ;
flag: = false ;
while not eof ( input) do begin
readln ( input, s) ;
GetWords( s, words, n) ;
if not flag then
for i: = 1 to length( words[ 1 ] ) do
include( first, words[ 1 ] [ i] ) ;
flag: = true ;
for i: = 1 to n do begin
j: = 1 ;
k: = 0 ; {Количество букв в текущем слове, содержащихся также в первом слове}
temp: = '(' ;
for j: = 1 to length( words[ i] ) do begin
if words[ i] [ j] in first then begin
temp: = temp+ words[ i] [ j] ;
inc( k) ;
end ;
end ;
if k>= 3 then begin
temp: = temp+ ')' ;
write ( output, up( words[ i] ) , ' ' , temp, ' ' ) ;
end
else
write ( output, words[ i] , ' ' ) ;
end ;
end ;
close( input) ;
close( output) ;
end .
cHJvZ3JhbSBtYWluOwpjb25zdCBhbHBoYT1bJ9CQJy4uJ9CvJywgJ9CwJy4uJ9C/JywgJ9GAJy4uJ9GPJywgCiAgICAgICAgICAgICcuJywgJywnLCAnLScsICc6JywgJzsnLCAnPycsIAogICAgICAgICAgICAnIScsICciJ107CnR5cGUgVD1hcnJheVsxLi4xMDBdIG9mIHN0cmluZzsKdHlwZSBBPXNldCBvZiBjaGFyOwp2YXIgaSwgaiwgazogaW50ZWdlcjsKICAgIGZvdW5kLCBzLCB0ZW1wOiBzdHJpbmc7IAogICAgbjogaW50ZWdlcjsge9Ca0L7Qu9C40YfQtdGB0YLQstC+INC/0YDQvtGH0LjRgtCw0L3QvdGL0YUg0YHQu9C+0LJ9CiAgICB3b3JkczogVDsge9Cc0LDRgdGB0LjQsiDRgdC70L7Qsn0KICAgIGZpcnN0OiBBOyB70JzQvdC+0LbQtdGB0YLQstC+INCx0YPQutCyINC/0LXRgNCy0L7Qs9C+INGB0LvQvtCy0LB9CiAgICBmbGFnOiBib29sZWFuOwogICAgCgpwcm9jZWR1cmUgR2V0V29yZHMoczogc3RyaW5nOyB2YXIgYTogVDsgdmFyIG46IEludGVnZXIpOwp2YXIgX3dvcmQ6IFN0cmluZzsKICAgIGk6IEludGVnZXI7CmJlZ2luCiAgaTo9MTsKICBuOj0wOwogIHM6PXMrICcgJzsKICB3aGlsZSBpPGxlbmd0aChzKSBkbwogICAgaWYgc1tpXSBpbiBhbHBoYSB0aGVuIGJlZ2luCiAgICAgIF93b3JkOj0nJzsKICAgICAgd2hpbGUgKHNbaV0gaW4gYWxwaGEpIGFuZCAoaTxsZW5ndGgocykpIGRvIGJlZ2luCiAgICAgICAgX3dvcmQ6PV93b3JkK3NbaV07CiAgICAgICAgaW5jKGkpOwogICAgICBlbmQ7CiAgICAgIGlmIF93b3JkIDw+ICcgJyB0aGVuIGJlZ2luCiAgICAgICAgaW5jKG4pOwogICAg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QvtC00LXRgNC20LDRidC40YXRgdGPINGC0LDQutC20LUg0LIg0L/QtdGA0LLQvtC8INGB0LvQvtCy0LV9CiAgICAgIHRlbXA6PScoJzsKICAgICAgZm9yIGo6PTEgdG8gbGVuZ3RoKHdvcmRzW2ldKSBkbyBiZWdpbgogICAgICAgIGlmIHdvcmRzW2ldW2pdIGluIGZpcnN0IHRoZW4gYmVnaW4KICAgICAgICAgIHRlbXA6PXRlbXArd29yZHNbaV1bal07CiAgICAgICAgICBpbmMoayk7CiAgICAgICAgZW5kOwogICAgICBlbmQ7CiAgICAgIGlmIGs+PTMgdGhlbiBiZWdpbgogICAgICAgIHRlbXA6PXRlbXArJyknOwogICAgICAgIHdyaXRlKG91dHB1dCwgdXAod29yZHNbaV0pLCAnICcsIHRlbXAsICcgJyk7CiAgICAgIGVuZAogICAgICBlbHNlCiAgICAgICAgd3JpdGUob3V0cHV0LHdvcmRzW2ldLCAnICcpOwogICAgZW5kOwogIGVuZDsgIAogIGNsb3NlKGlucHV0KTsKICBjbG9zZShvdXRwdXQpOwplbmQu
compilation info
Free Pascal Compiler version 2.2.0 [2009/11/16] for i386
Copyright (c) 1993-2007 by Florian Klaempfl
Target OS: Linux for i386
Compiling prog.pas
prog.pas(2,24) Error: Ordinal expression expected
prog.pas(23,9) Error: Incompatible types: got "Char" expected "Byte"
prog.pas(25,15) Error: Incompatible types: got "Char" expected "Byte"
prog.pas(45,18) Error: Constant and CASE types do not match
prog.pas(46,17) Error: Constant and CASE types do not match
prog.pas(46,17) Error: duplicate case label
prog.pas(46,30) Error: Ordinal expression expected
prog.pas(46,50) Error: Ordinal expression expected
prog.pas(47,17) Error: Constant and CASE types do not match
prog.pas(47,17) Error: duplicate case label
prog.pas(47,30) Error: Ordinal expression expected
prog.pas(47,50) Error: Ordinal expression expected
prog.pas(64,9) Warning: Variable "first" does not seem to be initialized
prog.pas(87,4) Fatal: There were 12 errors compiling module, stopping
Fatal: Compilation aborted
Error: /usr/bin/ppc386 returned an error exitcode (normal if you did not specify a source file to be compiled)
stdout