Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- program l2e1uvp;
- {Ivan Ryvonenko, PM-12}
- {change odd digits of the first num with the max digit of the second num}
- {without arrays}
- uses crt;
- var
- max_d:integer;
- first,second,result,step_ten:longint;
- begin
- clrscr;
- write('Enter first and second num: ');
- readln(first,second);
- max_d:=second mod 10;
- while second>=1 do
- begin
- if (second mod 10)>max_d then
- max_d:=second mod 10 ;
- second:=second div 10;
- end;
- result:=0;
- step_ten:=1;
- while first>=1 do
- begin
- if (first mod 10) mod 2 = 0 then
- result:=result + max_d*step_ten
- else
- result:=result + (first mod 10)*step_ten;
- step_ten:=step_ten*10;
- first:=first div 10;
- end;
- writeln('result is : ',result);
- readln;
- end.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement