GamerSK

Max, Min, parne a neparne cifri

Jan 31st, 2017
147
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pascal 0.54 KB | None | 0 0
  1. //Parne, neparne min a max
  2. program operaciesciframi;
  3. {$APPTYPE CONSOLE}
  4. uses SysUtils;
  5. var c,pc,nc,max,min:byte;
  6.     x:word;
  7. begin
  8.   write('Zadajte cislo: ');
  9.   readln(x);
  10.   pc:=0;
  11.   nc:=0;
  12.   max:=0;
  13.   min:=255;
  14.   while x<>0 do
  15.     begin
  16.       c:= x mod 10;
  17.       x:= x div 10;
  18.       if c mod 2 = 0 then pc:=pc+1;
  19.       if c mod 2 <> 0 then nc:=nc+1;
  20.       if c > max then max:=c;
  21.       if c < min then min:=c;
  22.     end;
  23.   writeln('MAX: ',max);
  24.   writeln('MIN: ',min);
  25.   writeln('PAR: ',pc);
  26.   writeln('NEPAR: ',nc);
  27.   readln;
  28. end.
Advertisement
Add Comment
Please, Sign In to add comment