ArfIsAToe

telifoun 3310

Apr 10th, 2019
239
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pascal 2.12 KB | None | 0 0
  1. program TrentTroisDix;
  2. uses WinCrt;
  3. Type
  4.     mat = Array [1..10,1..10] of char ;
  5. var
  6.     msg : string ;
  7. Function verif(ch : string ):boolean;
  8.     var
  9.         vf : Boolean;                                                                                                          //7777133166130661881313317777
  10.         a,c: integer;
  11.         h  : char   ;
  12.     begin
  13.         vf:= true;
  14.         if ch[1] = '1' then
  15.             vf := False
  16.         Else
  17.             begin
  18.                 h:= ch[1];
  19.                 c:=0;
  20.                 a:=1;
  21.                 while (vf= true) and (a<=Length(ch)) do
  22.                     begin
  23.                         if ch[a] = h then
  24.                             begin
  25.                                 c:=c+1;
  26.                                 if  (not(h in ['9','7']) and (c>=4) ) or (c>=5) then
  27.                                     vf := false
  28.                              end
  29.                         else
  30.                         if  (ch[a] <> h) and not (ch[a]in ['1','0'])   then
  31.               vf := false
  32.                         else  if not(ch[a] in ['0'..'9']) then
  33.                             vf:= false
  34.                         Else
  35.                             begin
  36.                             h:=ch[a+1];
  37.                                 c:=0;
  38.                             end;
  39.                         a:=a+1;    
  40.                     end;
  41.             end;
  42.         verif := vf;           
  43.     end;
  44.    
  45.     procedure saisi(var msg : string );
  46.         Begin
  47.             repeat
  48.                 write('Msg= ');
  49.                  readln(msg);
  50.                  writeln(verif(msg))
  51.             until verif(msg);
  52.         end;
  53.  
  54.         procedure rempM(var m : mat );
  55.             var
  56.                 x,l,c,lim : integer;
  57.             Begin
  58.                 x:=97;
  59.                 for l:=2 to 9 do
  60.                     begin
  61.                         if l in [7,9] then
  62.                          lim :=4
  63.                         Else
  64.                             lim:=3;
  65.                         for c:=1 to lim do
  66.                             begin
  67.                                 m[l,c]:=chr(x);
  68.                                 x:=x+1;
  69.                                
  70.                             end;
  71.                        
  72.                     end;
  73.            
  74.             End;
  75.  
  76.             function aff(ch: string):string;
  77.                 var
  78.                     c : String;
  79.                     a,x,b: integer;
  80.                     h: char;
  81.                     m : mat;
  82.                 begin
  83.                     rempm(m);
  84.                     While ch[Length(ch)] in ['1','0'] do
  85.                      delete(ch,Length(ch),1);
  86.                     ch:='1'+ch;
  87.                     c:='';               
  88.                     repeat
  89.                         h:=ch[Length(ch)];
  90.                         x:=0;
  91.                         b:= Length(ch);
  92.                         while not(ch[b] in ['1','0'])do
  93.                             Begin
  94.                                 b:=b-1;
  95.                                 x:=x+1;
  96.                             end;
  97.                         if ch[b]='0' then
  98.                             c := ' '+m[ord(ch[b+1])-48,x]+c
  99.                         Else
  100.                             c := m[ord(ch[b+1])-48,x]+c ;
  101.                         delete(ch,Length(ch)-x,x+1);
  102.                     until Length(ch) = 0 ;
  103.                     aff:=c;
  104.                 end;
  105. Begin
  106.     saisi(msg);
  107.     writeln(aff(msg));
  108. End.
Advertisement
Add Comment
Please, Sign In to add comment