Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // EXE: http://machalda.cekuj.net/d.php?f=29
- program soubor1;
- var f: text;
- pom: char;
- soubor: string;
- volba: integer;
- kod:integer;
- procedure encode();
- var int:integer;
- ch:char;
- g:text;
- begin
- reset(f);
- assign(g,'output.txt');
- rewrite(g);
- while not(eof(f)) do
- begin
- read(f,ch);
- int:=ord(ch);
- int:=int+kod;
- ch:=chr(int);
- write(g,ch);
- end;
- close(f);
- close(g);
- end;
- procedure decode();
- var int:integer;
- ch:char;
- g:text;
- begin
- reset(f);
- assign(g,'output.txt');
- rewrite(g);
- while not(eof(f)) do
- begin
- read(f,ch);
- int:=ord(ch);
- int:=int-kod;
- ch:=chr(int);
- write(g,ch);
- end;
- close(f);
- close(g);
- end;
- begin
- writeln('###########################################################');
- writeln('# Pouzit "input.txt" ? 1=ano | 0=ne | 666=konec');
- write('#-> volba: ');
- readln(volba);
- case volba of
- 1:assign(f, 'input.txt');
- 0:
- begin
- writeln('# Zadej cestu a nazev souboru');
- write('#-> soubor: ');
- readln(soubor);
- if soubor = 'output.txt' then writeln('# ERROR - pouziti souboru output.txt neni povoleno')
- else assign(f, soubor);
- end;
- else volba:= 666;
- end;
- if volba <> 666 then
- begin
- writeln('# Zadej kod');
- write('#-> cislo: ');
- readln(kod);
- writeln('# |E|ncode |D|ecode |K|onec');
- write('#-> akce: ');
- readln(pom);
- if pom = 'E' then encode()
- else if pom = 'D' then decode();
- writeln('############################ KONEC ###########################');
- end
- else
- begin
- writeln('########################## KONEC ##########################');
- end;
- readln;
- end.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement