thieumao

Dịch vòng sang trái 2 đơn vị

May 14th, 2013
131
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pascal 1.37 KB | None | 0 0
  1. program GiaiMa;
  2. uses crt;
  3. type mang=array[1..20] of string;
  4. var
  5.   F,F2: Text;
  6.   path,path2,temp: string;
  7.   s: mang;
  8.   ch:char;
  9.   i,j,lech:byte;
  10. {*****DAO NGUOC CHUOI*****}
  11. function nguoc(str: string):string;
  12. var
  13.   i:byte;
  14. begin
  15.   nguoc:='';
  16.   for i:=length(str) downto 1  do nguoc:=nguoc+str[i];
  17. end;
  18. {*****QUAY VONG *****}
  19. function vong(str: string; v:byte):string;
  20. var i,so:byte;
  21. begin
  22.   vong:='';
  23.   for i:=1 to length(str) do
  24.     begin
  25.       so:=ord(str[i]);
  26.       if (so>=65) and (so<=90) then
  27.         begin
  28.           so:=(so-65-v+26) mod 26 + 65;
  29.           vong:=vong+chr(so+32);
  30.         end
  31.       else
  32.         begin
  33.           vong:=vong+chr(so);
  34.         end;
  35.     end;
  36. end;
  37. begin
  38.   clrscr;
  39.   {write('Nhap path file: ');='mao.txt';
  40.   readln(path);}
  41.   path:='/home/thieumao/Desktop/doanma.txt';
  42.   assign(F, path);
  43.   reset(F);
  44.   i:=0;
  45.   writeln('***BAN MA***');
  46.   while (not eof(f)) do
  47.     begin
  48.       while (not eoln(F)) do
  49.         begin
  50.           i:=i+1;
  51.           readln(F,s[i]); writeln(i:2,' ',s[i]);
  52.         end;
  53.       {readln(F); writeln;}
  54.     end;
  55.   close(F);
  56.   writeln;
  57.  
  58.   lech:=2;
  59.   writeln('***BAN RO***');
  60.   path2:='/home/thieumao/Desktop/giaima.txt';
  61.   assign(F2, path2);
  62.   rewrite(F2);
  63.   for j:=1 to i do
  64.     begin
  65.       writeln(F2, vong(s[j],lech) );
  66.       writeln(j:2,' ', vong(s[j],lech) );
  67.     end;
  68.   close(F2);
  69. end.
Advertisement
Add Comment
Please, Sign In to add comment