Jahwi

Untitled

Jan 15th, 2016
108
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.75 KB | None | 0 0
  1. @echo off
  2. title Spacing chalenge
  3. setlocal enabledelayedexpansion
  4. ::In response to Icarus's spacing challenge
  5. ::By Jahwi
  6. ::Another fun challenge.
  7. :a
  8. cls
  9. set /p input=Enter String:
  10. set space=
  11. set spacex=
  12. set v=
  13. ::determine the number of letters in the string
  14. echo !input!>!temp!\string.txt
  15. for %%? in (!temp!\string.txt) do ( set /a strlength=%%~z? - 2 )
  16. if !strlength! GTR 41 echo Invalid Input&&goto :a
  17. ::determine if length is even or odd and do stuff
  18. set /a tmpa=!strlength!/2
  19. set /a tmpb=!tmpa!*2
  20. if not "!tmpb!"=="!strlength!" set v=-1
  21. set /a tmpspace=41-!strlength!
  22. set /a spaceb=(!tmpspace!/2)!v!
  23. if "!tmpb!"=="!strlength!" (
  24. set /a spacec=!spaceb!-1
  25. )
  26. for /l %%a in (1,1,!spaceb!) do (
  27. set space=!space!
  28. )
  29. if not "!tmpb!"=="!strlength!" set spacex=!space!
  30. if "!tmpb!"=="!strlength!" (
  31. for /l %%b in (1,1,!spacec!) do (
  32. set spacex=!spacex!
  33. )
  34. )
  35. set variable=!input!
  36. ::if "!strlength!"=="
  37. echo #########################################
  38. echo # #
  39. echo # #
  40. echo # #
  41. echo # #
  42. echo # #
  43. echo # #
  44. echo # #
  45. echo #!space!!variable!!spacex!#
  46. echo # #
  47. echo # #
  48. echo # #
  49. echo # #
  50. echo # #
  51. echo # #
  52. echo # #
  53. echo # #
  54. echo #########################################
  55. pause
  56. goto :a
Advertisement
Add Comment
Please, Sign In to add comment