GamerSK

cifry

Dec 15th, 2016
184
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pascal 0.75 KB | None | 0 0
  1. program min_max_cifry;
  2. uses crt;
  3. type cifry=0..9999;
  4.      cifra=0..9;
  5. var c:cifry;
  6.     c1,c2,c3,c4,max,min:cifra;
  7. begin
  8.   write('Zadajte 4ciferne cislo: ');
  9.   textcolor(lightgreen);
  10.   readln(c);
  11.   normvideo;
  12.   max:=0;
  13.   min:=9;
  14.   c1:= c mod 10;
  15.   c:= c div 10;
  16.   c2:= c mod 10;
  17.   c:= c div 10;
  18.   c3:= c mod 10;
  19.   c:= c div 10;
  20.   c4:= c mod 10;
  21.   if c1<min then min:=c1;
  22.   if c2<min then min:=c2;
  23.   if c3<min then min:=c3;
  24.   if c4<min then min:=c4;
  25.   if c1>max then max:=c1;
  26.   if c2>max then max:=c2;
  27.   if c3>max then max:=c3;
  28.   if c4>max then max:=c4;
  29.   write('Najmensia cifra: ');
  30.   textcolor(yellow);
  31.   writeln(min);
  32.   normvideo;
  33.   write('Najvacsia cifra: ');
  34.   textcolor(yellow);
  35.   writeln(max);
  36.   normvideo;
  37.   readln;
  38. end.
Advertisement
Add Comment
Please, Sign In to add comment