Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- program ejer14(input,output);
- procedure validar(var x :longint);
- begin
- repeat
- read(x);
- until(x>0);
- end;
- function invertirNumero(numero:longint):longint;
- var suma,dig:longint;
- begin
- suma:=0;
- while numero <>0 do
- begin
- dig:= numero mod 10;
- suma:=suma+dig;
- numero:= numero div 10;
- end;
- invertirNumero:=suma;
- end;
- function sumaDigitos(numero:longint):longint;
- var suma,dig:longint;
- begin
- suma:=0;
- while numero <>0 do
- begin
- dig:= numero mod 10;
- suma:=suma+dig;
- numero:= numero div 10;
- end;
- sumaDigitos:=suma;
- end;
- function especial(numero:longint):longint;
- var aux,inv,sdig:longint;
- begin
- inv:=invertirNumero(numero);
- sdig:=sumaDigitos(numero);
- aux:= 3 *inv + sdig;
- especial:=aux;
- end;
- function esEspecial(numero:longint):boolean;
- var aux:longint;
- begin
- aux:=especial(numero);
- if aux<> numero then
- begin
- esEspecial:=false;
- end
- else
- begin
- esEspecial:=true;
- end;
- end;
- var numero:longint;
- begin
- validar(numero);
- if esEspecial(numero)=true then
- begin
- write('SI');
- end
- else
- begin
- write('NO');
- end;
- end.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement