PseudoD, 688 579579 521 bytes
utilizar mate.pseudo
utilizar entsal.pseudo
adquirir n
adquirir a
adquirir r
adquirir i
fijar n a llamar LeerPalabra finargs
si son iguales n y CERO
llamar EscribirLineaescribir {0} finargs
salir
fin
fijar a a llamar ValorAbsoluto n finargs
fijar i a CERO
si comparar Importar.Ent.Comparar n < CERO
fijar r a {~}
sino
fijar r a {-}
fin
mientras comparar Importar.Ent.Comparar i < a
llamar Escribirescribir r finargs
si son iguales r y {~}
fijar r a {-}
Importar.Ent.Sumar i UNO i
sino
fijar r a {~}
fin
finbucle
si son iguales r y {~}
llamar Escribirescribir {~} finargs
fin
llamar Escribirescribir {0} finargs
Explain:
Read a number from STDIN;
If the number is zero (0); Then:
Writes 0 to STDOUT and exits;
End If;
If the number is less than zero (0); Then:
Set the fill character to "~";
Else:
Set the fill character to "-";
End If;
For i = 0; While i is less than abs(number); do:
Write the fill character to STDOUT;
If the fill character is "~":
Set the fill character to "-"
Increment i by one
Else:
Set the fill character to "~"
End if;
End for;
If the fill character is "~"; Then:
Write "~" to STDOUT;
End If;
Write "0" to STDOUT