Arfizato

challenge

Feb 8th, 2018
170
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pascal 2.36 KB | None | 0 0
  1. {a3mel program ta3tih enti 3dad ya3tik howa f tableau T el 3dad hedheka puissance 1-5
  2.  T1 := el somme mta3 el chiffres pairs ou impair . dependant 3al nature mta3 el variable compteur EXEMPLE "for a :=1 to 5 do" si a est pair ta3ti somme mta3 les chiffres pairs w l 3aks s7i7
  3.  T2 := el oppose mta3 T EXEMPLE  : T := 5/25/125/625/3125  T2 := 5/52/521/526/5213  :) :) :P         }
  4. Program puissanceTemchyWTzid ;
  5. uses WinCrt;
  6. Type
  7.     tab = Array [1..100] of Integer ;
  8. var
  9. t,tt,y: tab ;
  10. a,b,c,d,e,n : Integer;
  11. ss : string;
  12. Begin;
  13.     Repeat
  14.         Write('a5tar 3dad 1-9 : ');
  15.         Readln(n);
  16.     Until n in [2..9];
  17. // remplissage w el affichage mta3 tableau T
  18.     for a := 1 to 5 do
  19.         Begin
  20.             e := 1 ;
  21.             for b:= 1 to a do
  22.                 e    := e*n ;
  23.                 t[a] := e   ;
  24.         end;
  25.     write('T  :');
  26.     For a := 1 to 5 do
  27.     Write(t[a]:6);
  28.     writeln;
  29. // remplissage w el affichage mta3 tableau T1 :
  30.     for a :=1 to 5 do
  31.         Begin
  32.             if a mod 2 =0 then
  33.                 Begin
  34.                  str(t[a],ss);
  35.                  for b:=1 to Length(ss) do
  36.                      Begin
  37.                          val(copy(ss,b,1),c,d);
  38.                          If c mod 2 = 0 then
  39.                             tt[a] := tt[a]+c ;
  40.                      end;
  41.                  end
  42.             Else
  43.                 Begin
  44.                     Str(t[a],ss);
  45.                     for b:=1 to Length(ss) do
  46.                      Begin
  47.                          val(copy(ss,b,1),c,d);
  48.                          if c mod 2 <> 0 then
  49.                             tt[a] := tt[a]+c ;
  50.                      end;
  51.                 end;
  52.         end;
  53.     write('T1 :');
  54.     for a:=1 to 5 do
  55.     write(tt[a]:6);
  56. // Remplissage w affichage mta3 T2 :
  57.     case n of
  58.     6..9 : for a:=1 to 5 do
  59.         Begin
  60.             str(t[a],ss);
  61.             case Length(ss) of
  62.                 1 : y[a] := t[a] ;
  63.                 2 : y[a] := t[a] div 10 + (t[a] mod 10)*10 ;
  64.                 3 : y[a] := t[a] div 100 + ((t[a] mod 100)div 10)*10 + ((t[a] mod 100)mod 10)*100 ;
  65.                 4 : y[a] := t[a] div 1000 + ((t[a] mod 1000)div 100)*10 + ((t[a] mod 100)div 10)*100 + ((t[a] mod 100)mod 10)*1000 ;
  66.                 5 : y[a] := t[a] div 10000 + ((t[a] mod 10000)div 1000)*10 + ((t[a] mod 1000) div 100)*100+ ((t[a] mod 100)div 10)*1000 + ((t[a] mod 100)mod 10)*10000 ;
  67.             end;
  68.         end;
  69.     2..5 : for a:=1 to 5 do
  70.         Begin
  71.             str(t[a],ss);
  72.             case Length(ss) of
  73.                 1 : y[a] := t[a] ;
  74.                 2 : y[a] := t[a] div 10 + (t[a] mod 10)*10 ;
  75.                 3 : y[a] := t[a] div 100 + ((t[a] mod 100)div 10)*10 + ((t[a] mod 100)mod 10)*100 ;
  76.                 4 : y[a] := t[a] div 1000 + ((t[a] mod 1000)div 100)*10 + ((t[a] mod 100)div 10)*100 + ((t[a] mod 100)mod 10)*1000 ;
  77.             end;
  78.         end;
  79.     end;
  80.     writeln;
  81.     write('T2 :');
  82.     for a:=1 to 5 do
  83.         write(y[a]:6);
  84.  
  85. end.
Advertisement
Add Comment
Please, Sign In to add comment