回复 58# 77七
实际上不喜欢为了让别人看起来自己写的代码行数较少,而强行将多行变成一行,比较喜欢你的风格,虽然从行数上看代码较长,但是一目了然,清清楚楚,最近我好像也有点给带偏了。
给自己代码较长强行找点理由。既然对于这个问题来说,效率不是那么重要,就来个数据全定义代码,这样子判断起来就简单多了,要是有空的话,帮忙测试一下耗时情况:- @echo off
- for /l %%i in (1,1,12) do (
- for /l %%j in (1,1,31) do (
- if %%i lss 10 (
- if %%j lss 10 (
- set _"%%i/%%j"=0
- set _"0%%i/0%%j"=0
- ) else (
- set _"%%i/%%j"=0
- set _"0%%i/%%j"=0
- )
- ) else (
- if %%j lss 10 (
- set _"%%i/%%j"=0
- set _"%%i/0%%j"=0
- ) else (
- set _"%%i/%%j"=0
- )
- )
- )
- )
- for %%i in (2 4 6 9) do (
- set _"%%i/31"=
- set _"0%%i/31"=
- )
- set _"11/31"=
- set _"2/30"=
- set _"02/30"=
- setlocal enabledelayedexpansion
- :o
- set/p "md=Please Input the Date (MM/DD):"
- if defined _"!md!" (
- echo,Input Correct
- ) else (
- echo,Input Error
- goto :o
- )
- pause
复制代码
|